diff --git a/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs b/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs index 7a2ca220..b62bed77 100644 --- a/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs +++ b/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs @@ -1,4 +1,4 @@ -use crate::{gui::{gui_elements::MutexTIMManager, main_tab::MainTab, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow}; +use crate::{gui::{MutexTIMManager, main_tab::MainTab, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow}; use super::FileTab; use rfd::FileDialog; use slint::SharedString; diff --git a/src/Tools/tim_tool/src/gui/file_tab/mod.rs b/src/Tools/tim_tool/src/gui/file_tab/mod.rs index 6af74e3e..ca6fc286 100644 --- a/src/Tools/tim_tool/src/gui/file_tab/mod.rs +++ b/src/Tools/tim_tool/src/gui/file_tab/mod.rs @@ -1,6 +1,6 @@ mod callbacks; -use crate::gui::gui_elements::MutexTIMManager; +use crate::gui::MutexTIMManager; use super::{main_tab::SharedMainTab, MainWindowRef, display_error}; use slint::{Image, SharedString}; use std::{cell::RefCell, rc::Rc}; diff --git a/src/Tools/tim_tool/src/gui/gui_elements.rs b/src/Tools/tim_tool/src/gui/gui_elements.rs deleted file mode 100644 index a05f349e..00000000 --- a/src/Tools/tim_tool/src/gui/gui_elements.rs +++ /dev/null @@ -1,28 +0,0 @@ -use super::create_vram_bg; -use super::main_tab::SharedMainTab; -use super::MainWindowRef; -use super::{file_tab::{FileTab, SharedFileTab}, main_tab::MainTab}; -use std::{rc::Rc, sync::Mutex}; -use tim_tool::logic::TIMManager; - -pub type MutexTIMManager = Rc>; - -pub struct GUIElements { - _file_tab: SharedFileTab, - _main_tab: SharedMainTab, -} - -impl GUIElements { - pub fn new(main_window: MainWindowRef, tim_manager: MutexTIMManager) -> Result { - main_window.borrow().set_main_tab_vram_bg(GUIElements::create_bg()?); - - let _main_tab = MainTab::new(main_window.clone(), tim_manager.clone()); - let _file_tab = FileTab::new(main_window.clone(), _main_tab.clone(), tim_manager); - - Ok(GUIElements{_file_tab, _main_tab}) - } - - fn create_bg() -> Result { - Ok(slint::Image::from_rgba8_premultiplied(create_vram_bg(320, 256).ok_or(slint::PlatformError::Other("Failed creating VRAM background image".to_string()))?)) - } -} \ No newline at end of file diff --git a/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs b/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs index 274a3cc0..b1c4724b 100644 --- a/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs +++ b/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs @@ -1,4 +1,4 @@ -use crate::{gui::gui_elements::MutexTIMManager, MainWindow, display_information}; +use crate::{gui::MutexTIMManager, MainWindow, display_information}; use super::MainTab; pub fn on_move_vram_image() -> impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static { diff --git a/src/Tools/tim_tool/src/gui/main_tab/mod.rs b/src/Tools/tim_tool/src/gui/main_tab/mod.rs index a4bc4007..00748d63 100644 --- a/src/Tools/tim_tool/src/gui/main_tab/mod.rs +++ b/src/Tools/tim_tool/src/gui/main_tab/mod.rs @@ -1,6 +1,6 @@ mod callbacks; -use crate::{gui::{gui_elements::MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImage}; +use crate::{gui::{MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImage}; use super::MainWindowRef; use slint::{Model, SharedString}; use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}}; diff --git a/src/Tools/tim_tool/src/gui/mod.rs b/src/Tools/tim_tool/src/gui/mod.rs index 639727b5..00397052 100644 --- a/src/Tools/tim_tool/src/gui/mod.rs +++ b/src/Tools/tim_tool/src/gui/mod.rs @@ -1,19 +1,42 @@ mod file_tab; -mod gui_elements; mod main_tab; use crate::MainWindow; +use file_tab::{FileTab, SharedFileTab}; +use main_tab::{MainTab, SharedMainTab}; use rfd::MessageDialog; -use std::{cell::RefCell, rc::Rc}; +use std::{cell::RefCell, rc::Rc, sync::Mutex}; use slint::{Rgba8Pixel, SharedPixelBuffer}; +use tim_tool::logic::TIMManager; use tiny_skia::{Rect, Transform}; -pub use gui_elements::GUIElements; +type MainWindowRef = Rc>; + +pub type MutexTIMManager = Rc>; pub const VRAM_WIDTH:usize = 1024; pub const VRAM_HEIGHT:usize = 512; -type MainWindowRef = Rc>; +pub struct GUIElements { + _file_tab: SharedFileTab, + _main_tab: SharedMainTab, +} + +impl GUIElements { + pub fn new(main_window: MainWindowRef, tim_manager: MutexTIMManager) -> Result { + main_window.borrow().set_main_tab_vram_bg(GUIElements::create_bg()?); + + let _main_tab = MainTab::new(main_window.clone(), tim_manager.clone()); + let _file_tab = FileTab::new(main_window.clone(), _main_tab.clone(), tim_manager); + + Ok(GUIElements{_file_tab, _main_tab}) + } + + fn create_bg() -> Result { + Ok(slint::Image::from_rgba8_premultiplied(create_vram_bg(320, 256).ok_or(slint::PlatformError::Other("Failed creating VRAM background image".to_string()))?)) + } +} + pub fn display_information(title: impl Into, text: impl Into) { MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Info).set_description(text).show();