topic/bg/project-gui #21
|
@ -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<Mutex<TIMManager>>;
|
||||
|
||||
pub fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
||||
return move |file_tab, main_window| -> Result<(), Error> {
|
||||
|
|
|
@ -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<slint::VecModel<SharedString>>
|
||||
|
|
|
@ -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<Mutex<TIMManager>>;
|
||||
|
||||
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<GUIElements, slint::PlatformError> {
|
||||
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<slint::Image, slint::PlatformError> {
|
||||
|
|
|
@ -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<Mutex<TIMManager>>;
|
||||
|
||||
pub fn on_move_vram_image() -> impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static {
|
||||
return move |main_tab, _main_window, idx, dx, dy| {
|
||||
|
|
|
@ -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<Mutex<VRAM>>,
|
||||
vram: Arc<Mutex<VRAM>>,
|
||||
}
|
||||
|
||||
pub type SharedMainTab = Rc<RefCell<MainTab>>;
|
||||
|
||||
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<slint::StandardListViewItem> = 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::<VRAMImage>::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| {
|
||||
|
|
|
@ -14,7 +14,6 @@ pub const VRAM_WIDTH:usize = 1024;
|
|||
pub const VRAM_HEIGHT:usize = 512;
|
||||
|
||||
type MainWindowRef = Rc<RefCell<MainWindow>>;
|
||||
type GUIElementsRef = Rc<RefCell<GUIElements>>;
|
||||
|
||||
pub fn display_information(title: impl Into<String>, text: impl Into<String>) {
|
||||
MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Info).set_description(text).show();
|
||||
|
|
|
@ -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<RefCell<MainWindow>>,
|
||||
gui_elements: Rc<RefCell<GUIElements>>,
|
||||
tim_manager: Rc<Mutex<TIMManager>>,
|
||||
_gui_elements: Rc<RefCell<GUIElements>>,
|
||||
_tim_manager: Rc<Mutex<TIMManager>>,
|
||||
}
|
||||
|
||||
impl Application {
|
||||
fn new() -> Result<Application, slint::PlatformError> {
|
||||
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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue