Code clean up from live-stream #20
|
@ -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());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue