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 d9b66694..7a2ca220 100644 --- a/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs +++ b/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs @@ -1,12 +1,10 @@ -use crate::{gui::{main_tab::MainTab, VRAM_HEIGHT, VRAM_WIDTH},MainWindow}; +use crate::{gui::{gui_elements::MutexTIMManager, main_tab::MainTab, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow}; use super::FileTab; use rfd::FileDialog; use slint::SharedString; -use std::{rc::Rc, sync::Mutex}; -use tim_tool::logic::{tim::types::Encoding, TIMManager}; +use tim_tool::logic::tim::types::Encoding; use tool_helper::Error; -pub type MutexTIMManager = Rc>; pub fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { return move |file_tab, main_window| -> Result<(), Error> { 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 72003ecb..6af74e3e 100644 --- a/src/Tools/tim_tool/src/gui/file_tab/mod.rs +++ b/src/Tools/tim_tool/src/gui/file_tab/mod.rs @@ -1,16 +1,12 @@ mod callbacks; -use crate::MainWindow; -use super::main_tab::SharedMainTab; -use super::{GUIElements, GUIElementsRef, MainWindowRef, display_error}; +use crate::gui::gui_elements::MutexTIMManager; +use super::{main_tab::SharedMainTab, MainWindowRef, display_error}; use slint::{Image, SharedString}; -use std::cell::RefCell; -use std::rc::Rc; +use std::{cell::RefCell, rc::Rc}; use tim_tool::logic::tim::types::Encoding; use tool_helper::Error; -pub use callbacks::MutexTIMManager; - pub struct FileTab { main_window: MainWindowRef, encoding_options: Rc> diff --git a/src/Tools/tim_tool/src/gui/gui_elements.rs b/src/Tools/tim_tool/src/gui/gui_elements.rs index 39e1048b..a05f349e 100644 --- a/src/Tools/tim_tool/src/gui/gui_elements.rs +++ b/src/Tools/tim_tool/src/gui/gui_elements.rs @@ -1,25 +1,25 @@ -use std::cell::RefCell; -use std::rc::Rc; - use super::create_vram_bg; - use super::main_tab::SharedMainTab; use super::MainWindowRef; -use super::{file_tab::{FileTab, SharedFileTab, MutexTIMManager}, main_tab::MainTab}; +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 { - pub file_tab: SharedFileTab, - pub main_tab: SharedMainTab, + _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); + 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}) + Ok(GUIElements{_file_tab, _main_tab}) } fn create_bg() -> Result { 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 838b60fd..274a3cc0 100644 --- a/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs +++ b/src/Tools/tim_tool/src/gui/main_tab/callbacks.rs @@ -1,9 +1,5 @@ -use crate::{gui::{VRAM_HEIGHT, VRAM_WIDTH}, MainWindow, display_information}; +use crate::{gui::gui_elements::MutexTIMManager, MainWindow, display_information}; use super::MainTab; -use std::{rc::Rc, sync::Mutex}; -use tim_tool::logic::{tim::types::Encoding, TIMManager}; - -pub type MutexTIMManager = Rc>; pub fn on_move_vram_image() -> impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static { return move |main_tab, _main_window, idx, dx, dy| { 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 b1ee3f03..a4bc4007 100644 --- a/src/Tools/tim_tool/src/gui/main_tab/mod.rs +++ b/src/Tools/tim_tool/src/gui/main_tab/mod.rs @@ -1,11 +1,10 @@ mod callbacks; -use crate::{gui::{VRAM_HEIGHT, VRAM_WIDTH}, MainWindow, VRAMImage}; -use super::{GUIElementsRef, MainWindowRef}; - +use crate::{gui::{gui_elements::MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, VRAMImage}; +use super::MainWindowRef; use slint::{Model, SharedString}; -use tim_tool::logic::tim::types::Encoding; use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}}; +use tim_tool::logic::tim::types::Encoding; struct VRAM { count: usize, @@ -32,14 +31,13 @@ impl VRAM { } pub struct MainTab { - main_window: MainWindowRef, - vram: Arc>, + vram: Arc>, } pub type SharedMainTab = Rc>; impl MainTab { - pub fn new(main_window: MainWindowRef, tim_manager: callbacks::MutexTIMManager) -> SharedMainTab { + pub fn new(main_window: MainWindowRef, tim_manager: MutexTIMManager) -> SharedMainTab { let vram_file_list:Vec = main_window.borrow().get_main_tab_vram_file_list().iter().collect(); let vram_file_list = Rc::new(slint::VecModel::from(vram_file_list)); let vram_image_list = Rc::new(slint::VecModel::from(Vec::::new())); @@ -47,7 +45,7 @@ impl MainTab { main_window.borrow().set_main_tab_vram_file_list(vram_file_list.clone().into()); main_window.borrow().set_main_tab_vram_images(vram_image_list.clone().into()); - let object = SharedMainTab::new(MainTab{main_window: main_window.clone(), vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, image_list: vram_image_list}))}.into()); + let object = SharedMainTab::new(MainTab{vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, image_list: vram_image_list}))}.into()); let (cloned_object, cloned_main_window, mut function) = (object.clone(), main_window.clone(), callbacks::on_move_vram_image()); main_window.borrow().on_move_vram_image(move |idx, dx, dy| { diff --git a/src/Tools/tim_tool/src/gui/mod.rs b/src/Tools/tim_tool/src/gui/mod.rs index 438d75fd..639727b5 100644 --- a/src/Tools/tim_tool/src/gui/mod.rs +++ b/src/Tools/tim_tool/src/gui/mod.rs @@ -14,7 +14,6 @@ pub const VRAM_WIDTH:usize = 1024; pub const VRAM_HEIGHT:usize = 512; type MainWindowRef = Rc>; -type GUIElementsRef = Rc>; pub fn display_information(title: impl Into, text: impl Into) { MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Info).set_description(text).show(); diff --git a/src/Tools/tim_tool/src/main.rs b/src/Tools/tim_tool/src/main.rs index 4a6b05f8..ed0ec90d 100644 --- a/src/Tools/tim_tool/src/main.rs +++ b/src/Tools/tim_tool/src/main.rs @@ -2,30 +2,28 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] mod gui; -use gui::{GUIElements, VRAM_WIDTH, VRAM_HEIGHT, display_information}; -use rfd::FileDialog; +use gui::{GUIElements, display_information}; use std::{cell::RefCell, rc::Rc, sync::Mutex}; use slint::SharedString; -use tim_tool::logic::{tim::types::Encoding, TIMManager}; -use tool_helper::Error; +use tim_tool::logic::TIMManager; slint::include_modules!(); struct Application { main_window: Rc>, - gui_elements: Rc>, - tim_manager: Rc>, + _gui_elements: Rc>, + _tim_manager: Rc>, } impl Application { fn new() -> Result { let main_window = Rc::new(RefCell::new(MainWindow::new()?)); - let tim_manager = Rc::new(Mutex::new(TIMManager::new())); + let _tim_manager = Rc::new(Mutex::new(TIMManager::new())); Ok(Application{ main_window: main_window.clone(), - gui_elements: Rc::new(RefCell::new(GUIElements::new(main_window.clone(), tim_manager.clone())?)), - tim_manager: tim_manager, + _gui_elements: Rc::new(RefCell::new(GUIElements::new(main_window.clone(), _tim_manager.clone())?)), + _tim_manager, }) }