Merge gui_elements into gui
This commit is contained in:
parent
a4fe26f112
commit
aaeeaf97c5
|
@ -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 super::FileTab;
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use slint::SharedString;
|
use slint::SharedString;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
mod callbacks;
|
mod callbacks;
|
||||||
|
|
||||||
use crate::gui::gui_elements::MutexTIMManager;
|
use crate::gui::MutexTIMManager;
|
||||||
use super::{main_tab::SharedMainTab, MainWindowRef, display_error};
|
use super::{main_tab::SharedMainTab, MainWindowRef, display_error};
|
||||||
use slint::{Image, SharedString};
|
use slint::{Image, SharedString};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
|
@ -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<Mutex<TIMManager>>;
|
|
||||||
|
|
||||||
pub struct GUIElements {
|
|
||||||
_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);
|
|
||||||
|
|
||||||
Ok(GUIElements{_file_tab, _main_tab})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_bg() -> Result<slint::Image, slint::PlatformError> {
|
|
||||||
Ok(slint::Image::from_rgba8_premultiplied(create_vram_bg(320, 256).ok_or(slint::PlatformError::Other("Failed creating VRAM background image".to_string()))?))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{gui::gui_elements::MutexTIMManager, MainWindow, display_information};
|
use crate::{gui::MutexTIMManager, MainWindow, display_information};
|
||||||
use super::MainTab;
|
use super::MainTab;
|
||||||
|
|
||||||
pub fn on_move_vram_image() -> impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static {
|
pub fn on_move_vram_image() -> impl FnMut(&mut MainTab, &MainWindow, i32, i32, i32) + 'static {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
mod callbacks;
|
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 super::MainWindowRef;
|
||||||
use slint::{Model, SharedString};
|
use slint::{Model, SharedString};
|
||||||
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}};
|
use std::{cell::RefCell, ops::RangeInclusive, rc::Rc, sync::{Arc, Mutex}};
|
||||||
|
|
|
@ -1,19 +1,42 @@
|
||||||
mod file_tab;
|
mod file_tab;
|
||||||
mod gui_elements;
|
|
||||||
mod main_tab;
|
mod main_tab;
|
||||||
|
|
||||||
use crate::MainWindow;
|
use crate::MainWindow;
|
||||||
|
use file_tab::{FileTab, SharedFileTab};
|
||||||
|
use main_tab::{MainTab, SharedMainTab};
|
||||||
use rfd::MessageDialog;
|
use rfd::MessageDialog;
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc, sync::Mutex};
|
||||||
use slint::{Rgba8Pixel, SharedPixelBuffer};
|
use slint::{Rgba8Pixel, SharedPixelBuffer};
|
||||||
|
use tim_tool::logic::TIMManager;
|
||||||
use tiny_skia::{Rect, Transform};
|
use tiny_skia::{Rect, Transform};
|
||||||
|
|
||||||
pub use gui_elements::GUIElements;
|
type MainWindowRef = Rc<RefCell<MainWindow>>;
|
||||||
|
|
||||||
|
pub type MutexTIMManager = Rc<Mutex<TIMManager>>;
|
||||||
|
|
||||||
pub const VRAM_WIDTH:usize = 1024;
|
pub const VRAM_WIDTH:usize = 1024;
|
||||||
pub const VRAM_HEIGHT:usize = 512;
|
pub const VRAM_HEIGHT:usize = 512;
|
||||||
|
|
||||||
type MainWindowRef = Rc<RefCell<MainWindow>>;
|
pub struct GUIElements {
|
||||||
|
_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);
|
||||||
|
|
||||||
|
Ok(GUIElements{_file_tab, _main_tab})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_bg() -> Result<slint::Image, slint::PlatformError> {
|
||||||
|
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<String>, text: impl Into<String>) {
|
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();
|
MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Info).set_description(text).show();
|
||||||
|
|
Loading…
Reference in New Issue