Skip to content

Commit 9633fcd

Browse files
committed
cut uuid
1 parent 206e886 commit 9633fcd

File tree

4 files changed

+17
-67
lines changed

4 files changed

+17
-67
lines changed

Cargo.lock

Lines changed: 0 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ log = "0.4"
2828
lazy_static = "1.4.0"
2929
once_cell = "1.18.0"
3030
rfd = "0.12.0"
31-
uuid = { version = "1.4.1", features = ["js", "fast-rng", "v4"] }
3231

3332
# You only need serde if you want app persistence:
3433
#serde = { version = "1", features = ["derive"] }

src/app.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ use crate::{
66
use egui::{mutex::Mutex, Align2, DroppedFile, FontId, RichText, TextStyle};
77
use egui_extras::{image::load_image_bytes, RetainedImage};
88

9-
use std::{cell::RefCell, io::Cursor, rc::Rc};
9+
use std::{
10+
cell::RefCell,
11+
collections::hash_map::DefaultHasher,
12+
hash::{Hash, Hasher},
13+
io::Cursor,
14+
rc::Rc,
15+
};
1016

1117
#[derive(Default)]
1218
pub struct MetadataTool {
@@ -111,6 +117,7 @@ impl MetadataTool {
111117

112118
pub fn load_files_or_err(&mut self, ui: &mut egui::Ui) {
113119
if !self.dropped_files.is_empty() {
120+
let mut hasher = DefaultHasher::new();
114121
ui.group(|ui| {
115122
for file in &self.dropped_files {
116123
if let Some(bytes) = Self::load_file_contents(file) {
@@ -138,7 +145,12 @@ impl MetadataTool {
138145

139146
if let Ok(raw_dmi) = dmi::RawDmi::load(bytes_reader) {
140147
let new_mwin = ImageWindow {
141-
id: uuid::Uuid::new_v4(),
148+
id: {
149+
for chunk in &raw_dmi.chunks_idat {
150+
chunk.data.hash(&mut hasher)
151+
}
152+
hasher.finish().to_string().into()
153+
},
142154
img: {
143155
let h = (ui.available_height() * 1.85) as u32;
144156
let w = (ui.available_width() * 1.85) as u32;
@@ -190,7 +202,7 @@ impl eframe::App for MetadataTool {
190202

191203
for mwindow in &self.windows {
192204
egui::Window::new(&mwindow.metadata.file_name)
193-
.id(mwindow.id.to_string().into())
205+
.id(mwindow.id)
194206
.open(&mut mwindow.is_open.borrow_mut())
195207
.show(ctx, |ui| {
196208
create_meta_viewer(mwindow, ui, &mwindow.metadata, &tst);

src/image_window.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use poll_promise::Promise;
66
use std::{cell::RefCell, rc::Rc};
77

88
pub struct ImageWindow {
9-
pub id: uuid::Uuid,
9+
pub id: egui::Id,
1010
pub img: Rc<RetainedImage>,
1111
pub dmi: dmi::RawDmi,
1212
pub metadata: Rc<ImageMetadata>,
@@ -26,7 +26,7 @@ pub fn create_meta_viewer(
2626
metadata: &Rc<ImageMetadata>,
2727
toasts: &RefCell<&mut Toasts>,
2828
) {
29-
egui::TopBottomPanel::bottom(format!("{}_meta", img_win.id)).show_inside(ui, |ui| {
29+
egui::TopBottomPanel::bottom(format!("{:?}_meta", img_win.id)).show_inside(ui, |ui| {
3030
ui.add_space(6.0);
3131
ui.allocate_ui_with_layout(
3232
vec2(ui.available_width(), ui.available_height()),

0 commit comments

Comments
 (0)