Get moving tiles sorted
This commit is contained in:
@@ -5,9 +5,11 @@ import { TabWidget } from "std-widgets.slint";
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
in-out property main_tab_vram_file_list <=> tab.vram_files;
|
||||
in-out property main_tab_vram_images <=> tab.vram_images;
|
||||
|
||||
callback main_tab_add_file_clicked <=> tab.add_file_clicked;
|
||||
callback main_tab_remove_file_clicked <=> tab.remove_file_clicked;
|
||||
callback move_vram_image <=> tab.move_vram_image;
|
||||
|
||||
title: "TIM Tool 0.1.0";
|
||||
width: tab_widget.width;
|
||||
|
@@ -2,9 +2,9 @@ import { VRAMArea } from "../vram-components.slint";
|
||||
import { Button, ComboBox, GroupBox, StandardListView } from "std-widgets.slint";
|
||||
|
||||
struct VRAMImage {
|
||||
img: image,
|
||||
x: int,
|
||||
y: int,
|
||||
img: image,
|
||||
x: int,
|
||||
y: int,
|
||||
}
|
||||
|
||||
export component MainTab inherits Rectangle {
|
||||
@@ -13,6 +13,7 @@ export component MainTab inherits Rectangle {
|
||||
|
||||
callback add_file_clicked();
|
||||
callback remove_file_clicked(int);
|
||||
callback move_vram_image(int, int, int);
|
||||
|
||||
width: group.width + group.x*2;
|
||||
height: group.height + group.y*2 + 32px;
|
||||
@@ -40,9 +41,43 @@ export component MainTab inherits Rectangle {
|
||||
for vram_image[i] in root.vram_images: VRAMArea {
|
||||
x: root.get_border_width()*1px;
|
||||
y: root.get_border_width()*1px;
|
||||
img: vram-image.img;
|
||||
img: vram-image.img;
|
||||
img_x: vram-image.x;
|
||||
img_y: vram-image.y;
|
||||
TouchArea {
|
||||
x: (parent.img_x + self.lines_crossed_x())*1px;
|
||||
y: (parent.img_y + self.lines_crossed_y())*1px;
|
||||
width: (parent.img.width + self.lines_crossed_width())*1px;
|
||||
height: (parent.img.height + self.lines_crossed_height())*1px;
|
||||
mouse-cursor: grab;
|
||||
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);
|
||||
|
||||
}
|
||||
pointer-event(event) => {
|
||||
if event.kind == PointerEventKind.up {
|
||||
self.mouse-cursor = MouseCursor.grab;
|
||||
}
|
||||
}
|
||||
|
||||
// Thanks to Cody the white tiger
|
||||
function lines_crossed_x() -> int {
|
||||
return parent.img_x/64;
|
||||
}
|
||||
|
||||
function lines_crossed_y() -> int {
|
||||
return parent.img_y/256;
|
||||
}
|
||||
|
||||
function lines_crossed_width() -> int {
|
||||
return ((parent.img_x + parent.img.width)/64) - self.lines_crossed_x();
|
||||
}
|
||||
|
||||
function lines_crossed_height() -> int {
|
||||
return ((parent.img_y + parent.img.height)/256) - self.lines_crossed_y();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
|
Reference in New Issue
Block a user