Compare commits
3 Commits
f68ef48296
...
ebf640520e
Author | SHA1 | Date |
---|---|---|
|
ebf640520e | |
|
b4c6cb70b6 | |
|
fb1ecf17c5 |
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,22 @@ impl TIMInfo {
|
|||
}
|
||||
|
||||
pub fn get_slint_images(&self) -> (slint::Image, Option<slint::Image>) {
|
||||
(slint::Image::from_rgba8_premultiplied(self.image_data.clone()), None)
|
||||
(slint::Image::from_rgba8_premultiplied(self.image_data.clone()), if let Some(palette) = &self.palette {
|
||||
let width = if palette.len() <= 16 {16} else {256};
|
||||
Some(Self::get_palette_image(palette, width, 1))
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
fn get_palette_image(palette: &Vec<Rgba8Pixel>, width: u32, height: u32) -> slint::Image {
|
||||
let mut image_data = SharedPixelBuffer::new(width, height);
|
||||
let dst_pixels = image_data.make_mut_slice();
|
||||
|
||||
for (idx, byte) in dst_pixels.iter_mut().enumerate() {
|
||||
*byte = if idx < palette.len() {palette[idx]} else {Rgba8Pixel::new(0, 0, 0, 0xFF)};
|
||||
}
|
||||
|
||||
slint::Image::from_rgba8_premultiplied(image_data.clone())
|
||||
}
|
||||
}
|
|
@ -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,8 +105,8 @@ 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_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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
cur_sel_y :=Text {
|
||||
in-out property <int> display_value;
|
||||
text: "Y: " + display_value;
|
||||
}
|
||||
ComboBox {
|
||||
model: ["4-bit", "16-bit", "24-bit"];
|
||||
|
@ -162,6 +196,33 @@ export component MainTab inherits Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
key-pressed(event) => {
|
||||
if(vram_files_list.current-item != -1) {
|
||||
if(event.text == Key.LeftArrow) {
|
||||
root.move_vram_image(vram_files_list.current-item, -1, 0);
|
||||
cur_sel_x.text = vram_images[vram_files_list.current-item].x;
|
||||
}
|
||||
|
||||
if(event.text == Key.RightArrow) {
|
||||
root.move_vram_image(vram_files_list.current-item, 1, 0);
|
||||
cur_sel_x.text = vram_images[vram_files_list.current-item].x;
|
||||
}
|
||||
|
||||
if(event.text == Key.UpArrow) {
|
||||
root.move_vram_image(vram_files_list.current-item, 0, -1);
|
||||
cur_sel_y.text = vram_images[vram_files_list.current-item].y;
|
||||
}
|
||||
|
||||
if(event.text == Key.DownArrow) {
|
||||
root.move_vram_image(vram_files_list.current-item, 0, 1);
|
||||
cur_sel_y.text = vram_images[vram_files_list.current-item].y;
|
||||
}
|
||||
}
|
||||
accept
|
||||
}
|
||||
}
|
||||
|
||||
function get_border_width() -> int {
|
||||
return 4;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue