Make image pos editable

This commit is contained in:
Jaby 2025-02-17 16:53:35 +01:00
parent fb1ecf17c5
commit b4c6cb70b6
2 changed files with 52 additions and 18 deletions

View File

@ -43,7 +43,7 @@ impl MainTab {
add_new_image(file_name, image, if image_palette.is_some() {1} else {0}, false);
if let Some(image_palette) = image_palette {
let file_name = file_name.clone() + " (Palette)";
let file_name = " => ".to_owned() + file_name.as_str() + " (Palette)";
add_new_image(&file_name, image_palette, 0, true);
}
}

View File

@ -1,5 +1,5 @@
import { VRAMArea } from "../vram-components.slint";
import { Button, ComboBox, GroupBox, StandardListView } from "std-widgets.slint";
import { Button, ComboBox, GroupBox, StandardListView, LineEdit } from "std-widgets.slint";
struct VRAMImage {
img: image,
@ -56,8 +56,8 @@ export component MainTab inherits Rectangle {
moved => {
self.mouse-cursor = MouseCursor.grabbing;
root.move_vram_image(i, (self.mouse-x - self.pressed-x)/1px, (self.mouse-y - self.pressed-y)/1px);
cur_sel_x.display_value = parent.img_x;
cur_sel_y.display_value = parent.img_y;
cur_sel_x.text = parent.img_x;
cur_sel_y.text = parent.img_y;
}
pointer-event(event) => {
if event.kind == PointerEventKind.up {
@ -65,8 +65,8 @@ export component MainTab inherits Rectangle {
}
if event.kind == PointerEventKind.down {
cur_sel_x.display_value = parent.img_x;
cur_sel_y.display_value = parent.img_y;
cur_sel_x.text = parent.img_x;
cur_sel_y.text = parent.img_y;
cur_sel_img.source = parent.img;
cur_sel_img.visible = true;
vram_files_list.current-item = i;
@ -105,10 +105,10 @@ export component MainTab inherits Rectangle {
model: root.vram_files;
current-item-changed(current-item) => {
cur_sel_x.display_value = root.vram_images[current-item].x;
cur_sel_y.display_value = root.vram_images[current-item].y;
cur_sel_img.source = root.vram_images[current-item].img;
cur_sel_img.visible = true;
cur_sel_x.text = root.vram_images[current-item].x;
cur_sel_y.text = root.vram_images[current-item].y;
cur_sel_img.source = root.vram_images[current-item].img;
cur_sel_img.visible = true;
}
}
HorizontalLayout {
@ -122,8 +122,8 @@ export component MainTab inherits Rectangle {
clicked => {
root.remove_file_clicked(vram_files_list.current_item);
vram_files_list.current-item = -1;
cur_sel_x.display_value = 0;
cur_sel_y.display_value = 0;
cur_sel_x.text = 0;
cur_sel_y.text = 0;
cur_sel_img.visible = false;
}
}
@ -144,13 +144,47 @@ export component MainTab inherits Rectangle {
image-fit: contain;
}
}
cur_sel_x := Text {
in-out property <int> display_value;
text: "X: " + display_value;
HorizontalLayout {
alignment: start;
VerticalLayout {
alignment: center;
Text {
text: "X: ";
}
}
cur_sel_x := LineEdit {
input-type: number;
text: 0;
width: 64pt;
accepted(text) => {
if(vram_files_list.current-item != -1) {
root.move_vram_image(vram_files_list.current-item, text.to-float() - vram_images[vram_files_list.current-item].x, 0);
self.text = vram_images[vram_files_list.current-item].x;
}
}
}
}
cur_sel_y :=Text {
in-out property <int> display_value;
text: "Y: " + display_value;
HorizontalLayout {
alignment: start;
VerticalLayout {
alignment: center;
Text {
text: "Y: ";
}
}
cur_sel_y := LineEdit {
input-type: number;
text: 0;
width: 64pt;
accepted(text) => {
if(vram_files_list.current-item != -1) {
root.move_vram_image(vram_files_list.current-item, 0, text.to-float() - vram_images[vram_files_list.current-item].y);
self.text = vram_images[vram_files_list.current-item].y;
}
}
}
}
ComboBox {
model: ["4-bit", "16-bit", "24-bit"];