Compare commits

..

No commits in common. "ebf640520e012c3d050434e3ddb9d4c9b45db6e5" and "f68ef482967bf9879562db09fb183c6bab779c31" have entirely different histories.

3 changed files with 19 additions and 96 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 = " => ".to_owned() + file_name.as_str() + " (Palette)";
let file_name = file_name.clone() + " (Palette)";
add_new_image(&file_name, image_palette, 0, true);
}
}

View File

@ -71,22 +71,6 @@ impl TIMInfo {
}
pub fn get_slint_images(&self) -> (slint::Image, Option<slint::Image>) {
(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())
(slint::Image::from_rgba8_premultiplied(self.image_data.clone()), None)
}
}

View File

@ -1,5 +1,5 @@
import { VRAMArea } from "../vram-components.slint";
import { Button, ComboBox, GroupBox, StandardListView, LineEdit } from "std-widgets.slint";
import { Button, ComboBox, GroupBox, StandardListView } 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.text = parent.img_x;
cur_sel_y.text = parent.img_y;
cur_sel_x.display_value = parent.img_x;
cur_sel_y.display_value = 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.text = parent.img_x;
cur_sel_y.text = parent.img_y;
cur_sel_x.display_value = parent.img_x;
cur_sel_y.display_value = 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.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;
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;
}
}
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.text = 0;
cur_sel_y.text = 0;
cur_sel_x.display_value = 0;
cur_sel_y.display_value = 0;
cur_sel_img.visible = false;
}
}
@ -144,47 +144,13 @@ export component MainTab inherits Rectangle {
image-fit: contain;
}
}
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_x := Text {
in-out property <int> display_value;
text: "X: " + 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;
}
}
}
cur_sel_y :=Text {
in-out property <int> display_value;
text: "Y: " + display_value;
}
ComboBox {
model: ["4-bit", "16-bit", "24-bit"];
@ -196,33 +162,6 @@ 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;
}