Skip to content

Commit

Permalink
implement forget_all_stored_images
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Dec 5, 2024
1 parent 6a3b2eb commit f950d1b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/information_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,7 @@ impl InformationPanel {
preview_handler(ui, panel_entry, &mut self.stored_images);
let number_of_stored_images = self.stored_images.len();
if number_of_stored_images > 10 {
if let Some(last_image) = self.stored_images.first() {
ui.ctx()
.forget_image(format!("file://{last_image}").as_str());
}
self.stored_images.shift_remove_index(0);
self.forget_last_stored_image(ui);
}
} else if let Some(mut content) = panel_entry.content() {
egui::ScrollArea::vertical()
Expand All @@ -346,6 +342,22 @@ impl InformationPanel {
}
}

fn forget_last_stored_image(&mut self, ui: &Ui) {
if let Some(last_image) = self.stored_images.first() {
ui.ctx()
.forget_image(format!("file://{last_image}").as_str());
}
self.stored_images.shift_remove_index(0);
}

#[allow(dead_code)]
fn forget_all_stored_images(&mut self, ui: &Ui) {
for image in &self.stored_images {
ui.ctx().forget_image(format!("file://{image}").as_str());
}
self.stored_images.clear();
}

fn load_meta_data(&mut self, item: &DirectoryEntry) {
let path_buf = item.to_path_buf();
if self.loaded_file_name != path_buf {
Expand Down

0 comments on commit f950d1b

Please sign in to comment.