Add palette flag that prevents deleting
This commit is contained in:
parent
ac6a46134e
commit
6ddca9e79f
|
@ -26,16 +26,24 @@ impl MainTab {
|
|||
let vram_image = VRAMImage{
|
||||
img: image,
|
||||
x: 0,
|
||||
y: 0
|
||||
y: 0,
|
||||
is_palette: false,
|
||||
};
|
||||
|
||||
self.vram_file_list.push(slint::StandardListViewItem::from(file_name.as_str()));
|
||||
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_image_list.remove(idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn move_vram_image(&mut self, idx: usize, dx: i32, dy: i32) {
|
||||
|
|
|
@ -16,7 +16,11 @@ pub const VRAM_HEIGHT:usize = 512;
|
|||
type MainWindowRef = Rc<RefCell<MainWindow>>;
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
mod gui;
|
||||
use gui::{GUIElements, VRAM_WIDTH, VRAM_HEIGHT};
|
||||
use gui::{GUIElements, VRAM_WIDTH, VRAM_HEIGHT, display_information};
|
||||
use rfd::FileDialog;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
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| {
|
||||
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");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ struct VRAMImage {
|
|||
img: image,
|
||||
x: int,
|
||||
y: int,
|
||||
is_palette: bool,
|
||||
}
|
||||
|
||||
export component MainTab inherits Rectangle {
|
||||
|
|
Loading…
Reference in New Issue