Code clean up from live-stream #20

Merged
jaby merged 4 commits from topic/jb/more-improvements into main 2025-03-13 19:56:22 +00:00
2 changed files with 6 additions and 8 deletions
Showing only changes of commit 02470d6bb7 - Show all commits

View File

@ -142,10 +142,9 @@ impl FileTab {
pub fn on_update_palette_size(&self, gui_elements: GUIElementsRef, mut function: impl FnMut(&mut GUIElements, &MainWindow, u32, u32) -> Result<(), Error> + 'static) {
let main_window_cloned = self.main_window.clone();
let gui_cloned = gui_elements.clone();
self.main_window.borrow().on_file_tab_update_palette_size(move |width, height| {
if let Err(error) = function(&mut gui_cloned.borrow_mut(), &main_window_cloned.borrow(), width as u32, height as u32) {
if let Err(error) = function(&mut gui_elements.borrow_mut(), &main_window_cloned.borrow(), width as u32, height as u32) {
display_error("Loadind file failed", &error.to_string());
}
});
@ -153,10 +152,9 @@ impl FileTab {
pub fn on_add_image(&self, gui_elements: GUIElementsRef, mut function: impl FnMut(&mut GUIElements, &MainWindow) -> Result<(), Error> + 'static) {
let main_window_cloned = self.main_window.clone();
let gui_cloned = gui_elements.clone();
self.main_window.borrow().on_file_tab_add_convert_image(move || {
if let Err(error) = function(&mut gui_cloned.borrow_mut(), &main_window_cloned.borrow()) {
if let Err(error) = function(&mut gui_elements.borrow_mut(), &main_window_cloned.borrow()) {
display_error("Adding file failed", &error.to_string());
}
});

View File

@ -140,17 +140,17 @@ impl MainTab {
pub fn on_move_vram_image(&self, gui_elements: GUIElementsRef, mut function: impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static) {
let main_window_cloned = self.main_window.clone();
let gui_cloned = gui_elements.clone();
self.main_window.borrow().on_move_vram_image(move |idx, dx, dy| {
function(&mut gui_cloned.borrow_mut().main_tab, &main_window_cloned.borrow(), idx, dx, dy);
function(&mut gui_elements.borrow_mut().main_tab, &main_window_cloned.borrow(), idx, dx, dy);
});
}
pub fn on_remove_file(&self, gui_elements: GUIElementsRef, mut function: impl FnMut(&mut MainTab, &MainWindow, i32) + 'static) {
let main_window_cloned = self.main_window.clone();
let gui_cloned = gui_elements.clone();
self.main_window.borrow().on_main_tab_remove_file_clicked(move |idx| {
function(&mut gui_cloned.borrow_mut().main_tab, &main_window_cloned.borrow(), idx);
function(&mut gui_elements.borrow_mut().main_tab, &main_window_cloned.borrow(), idx);
});
}
}