Creation of TIM Tool #15

Merged
jaby merged 32 commits from topic/jb/tim_tool/slint-test into main 2025-02-16 21:26:32 +00:00
4 changed files with 25 additions and 10 deletions
Showing only changes of commit 6ddca9e79f - Show all commits

View File

@ -26,16 +26,24 @@ impl MainTab {
let vram_image = VRAMImage{ let vram_image = VRAMImage{
img: image, img: image,
x: 0, x: 0,
y: 0 y: 0,
is_palette: false,
}; };
self.vram_file_list.push(slint::StandardListViewItem::from(file_name.as_str())); self.vram_file_list.push(slint::StandardListViewItem::from(file_name.as_str()));
self.vram_image_list.push(vram_image); self.vram_image_list.push(vram_image);
} }
pub fn remove_vram_file(&mut self, idx: usize) { pub fn remove_vram_file(&mut self, idx: usize) -> bool {
if let Some(element) = self.vram_image_list.iter().skip(idx).next() {
if element.is_palette {
return false;
}
}
self.vram_file_list.remove(idx); self.vram_file_list.remove(idx);
self.vram_image_list.remove(idx); self.vram_image_list.remove(idx);
return true;
} }
pub fn move_vram_image(&mut self, idx: usize, dx: i32, dy: i32) { pub fn move_vram_image(&mut self, idx: usize, dx: i32, dy: i32) {

View File

@ -16,7 +16,11 @@ pub const VRAM_HEIGHT:usize = 512;
type MainWindowRef = Rc<RefCell<MainWindow>>; type MainWindowRef = Rc<RefCell<MainWindow>>;
type GUIElementsRef = Rc<RefCell<GUIElements>>; type GUIElementsRef = Rc<RefCell<GUIElements>>;
fn display_error(title: &str, text: &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();
}
pub fn display_error(title: impl Into<String>, text: impl Into<String>) {
MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Error).set_description(text).show(); MessageDialog::new().set_title(title).set_level(rfd::MessageLevel::Error).set_description(text).show();
} }

View File

@ -2,7 +2,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod gui; mod gui;
use gui::{GUIElements, VRAM_WIDTH, VRAM_HEIGHT}; use gui::{GUIElements, VRAM_WIDTH, VRAM_HEIGHT, display_information};
use rfd::FileDialog; use rfd::FileDialog;
use std::{cell::RefCell, rc::Rc}; use std::{cell::RefCell, rc::Rc};
use slint::SharedString; use slint::SharedString;
@ -33,7 +33,9 @@ fn setup_main_tab(gui_elements_ref: Rc<RefCell<GUIElements>>) {
gui_elements.main_tab.on_remove_file(gui_elements_ref.clone(), move |main_tab, _main_window, idx| { gui_elements.main_tab.on_remove_file(gui_elements_ref.clone(), move |main_tab, _main_window, idx| {
if idx >= 0 { if idx >= 0 {
main_tab.remove_vram_file(idx as usize); if !main_tab.remove_vram_file(idx as usize) {
display_information("Removing VRAM file", "Can not remove palette. Delete image instead");
}
} }
}); });
} }

View File

@ -5,6 +5,7 @@ struct VRAMImage {
img: image, img: image,
x: int, x: int,
y: int, y: int,
is_palette: bool,
} }
export component MainTab inherits Rectangle { export component MainTab inherits Rectangle {