Display full image in main window preview
This commit is contained in:
parent
33e7b23ab2
commit
3549c1a709
|
@ -46,11 +46,12 @@ impl MainTab {
|
||||||
MainTab{main_window, vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, image_list: vram_image_list}))}
|
MainTab{main_window, vram: Arc::new(Mutex::new(VRAM{count: 0, file_list: vram_file_list, image_list: vram_image_list}))}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_new_vram_file(&mut self, file_name: &String, image: slint::Image, encoding: Encoding, image_palette: Option<slint::Image>) -> usize {
|
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, image: slint::Image, encoding: Encoding, image_palette: Option<slint::Image>) -> usize {
|
||||||
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
||||||
let mut add_new_image = |file_name: &String, image: slint::Image, encoding: Encoding, palette_count: i32, is_palette: bool| {
|
let mut add_new_image = |file_name: &String, full_image: slint::Image, image: slint::Image, encoding: Encoding, palette_count: i32, is_palette: bool| {
|
||||||
let encoding_str = if is_palette {"<Palette>"} else {encoding.to_str()};
|
let encoding_str = if is_palette {"<Palette>"} else {encoding.to_str()};
|
||||||
let vram_image = VRAMImage{
|
let vram_image = VRAMImage{
|
||||||
|
full_img: full_image,
|
||||||
img: image,
|
img: image,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
@ -63,12 +64,12 @@ impl MainTab {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut images_added = 1;
|
let mut images_added = 1;
|
||||||
add_new_image(file_name, image, encoding, if image_palette.is_some() {1} else {0}, false);
|
add_new_image(file_name, full_image, image, encoding, if image_palette.is_some() {1} else {0}, false);
|
||||||
if let Some(image_palette) = image_palette {
|
if let Some(image_palette) = image_palette {
|
||||||
let file_name = " => ".to_owned() + file_name.as_str() + " (Palette)";
|
let file_name = " => ".to_owned() + file_name.as_str() + " (Palette)";
|
||||||
|
|
||||||
images_added += 1;
|
images_added += 1;
|
||||||
add_new_image(&file_name, image_palette, encoding, 0, true);
|
add_new_image(&file_name, image_palette.clone(), image_palette, encoding, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
images_added
|
images_added
|
||||||
|
|
|
@ -6,7 +6,7 @@ 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;
|
||||||
use tim_tool::logic::Logic;
|
use tim_tool::logic::{tim::types::Encoding, Logic};
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
|
|
||||||
slint::include_modules!();
|
slint::include_modules!();
|
||||||
|
@ -88,8 +88,9 @@ fn setup_file_tab(gui_elements_ref: Rc<RefCell<GUIElements>>, logic_ref: Rc<RefC
|
||||||
let file_name = file_tab.get_file_name();
|
let file_name = file_tab.get_file_name();
|
||||||
let encoding = file_tab.get_encoding()?;
|
let encoding = file_tab.get_encoding()?;
|
||||||
let (image, palette_image) = logic.borrow().get_converted_unadded_tim_image(encoding)?;
|
let (image, palette_image) = logic.borrow().get_converted_unadded_tim_image(encoding)?;
|
||||||
|
let (full_image, _) = logic.borrow().get_converted_unadded_tim_image(Encoding::FullColor)?;
|
||||||
|
|
||||||
let images_created = main_tab.add_new_vram_file(&file_name, image, encoding, palette_image);
|
let images_created = main_tab.add_new_vram_file(&file_name, full_image, image, encoding, palette_image);
|
||||||
if let Err(error) = logic.borrow_mut().add_unadded_tim(images_created) {
|
if let Err(error) = logic.borrow_mut().add_unadded_tim(images_created) {
|
||||||
main_tab.pop_vram_files(images_created);
|
main_tab.pop_vram_files(images_created);
|
||||||
return Err(error);
|
return Err(error);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { VRAMArea } from "../vram-components.slint";
|
||||||
import { Button, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint";
|
import { Button, ComboBox, GroupBox, StandardListView, LineEdit, ScrollView, Slider } from "std-widgets.slint";
|
||||||
|
|
||||||
struct VRAMImage {
|
struct VRAMImage {
|
||||||
|
full_img: image,
|
||||||
img: image,
|
img: image,
|
||||||
x: int,
|
x: int,
|
||||||
y: int,
|
y: int,
|
||||||
|
@ -81,7 +82,7 @@ export component MainTab inherits Rectangle {
|
||||||
if event.kind == PointerEventKind.down {
|
if event.kind == PointerEventKind.down {
|
||||||
cur_sel_x.text = parent.img_x;
|
cur_sel_x.text = parent.img_x;
|
||||||
cur_sel_y.text = parent.img_y;
|
cur_sel_y.text = parent.img_y;
|
||||||
cur_sel_img.source = parent.img;
|
cur_sel_img.source = vram-image.full_img;
|
||||||
encoding_text.encoding_str = vram-image.encoding_str;
|
encoding_text.encoding_str = vram-image.encoding_str;
|
||||||
cur_sel_img.visible = true;
|
cur_sel_img.visible = true;
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ export component MainTab inherits Rectangle {
|
||||||
current-item-changed(current-item) => {
|
current-item-changed(current-item) => {
|
||||||
cur_sel_x.text = root.vram_images[current-item].x;
|
cur_sel_x.text = root.vram_images[current-item].x;
|
||||||
cur_sel_y.text = root.vram_images[current-item].y;
|
cur_sel_y.text = root.vram_images[current-item].y;
|
||||||
cur_sel_img.source = root.vram_images[current-item].img;
|
cur_sel_img.source = root.vram_images[current-item].full_img;
|
||||||
encoding_text.encoding_str = root.vram_images[current-item].encoding_str;
|
encoding_text.encoding_str = root.vram_images[current-item].encoding_str;
|
||||||
cur_sel_img.visible = true;
|
cur_sel_img.visible = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue