rect file selection

This commit is contained in:
2025-09-04 18:31:02 +02:00
parent cdd4151462
commit 735e825c7d
9 changed files with 187 additions and 24 deletions

View File

@@ -0,0 +1,39 @@
export const useSelectionRect = defineStore('selection-rect', {
state: () => ({
enabled: false as boolean,
a: {
x: 0 as number,
y: 0 as number,
},
b: {
x: 0 as number,
y: 0 as number,
},
}),
actions: {
set(a: { x: number; y: number }, b: { x: number; y: number }) {
this.a.x = a.x;
this.a.y = a.y;
this.b.x = b.x;
this.b.y = b.y;
this.enabled = true;
},
updateB(x: number, y: number) {
this.b.x = x;
this.b.y = y;
},
disable() {
this.enabled = false;
},
isMinSize(minPixels: number = 10) {
return (
Math.max(
Math.abs(this.a.x - this.b.x),
Math.abs(this.a.y - this.b.y)
) >= minPixels
);
},
},
});