rect file selection
This commit is contained in:
39
frontend/stores/selectionRect.ts
Normal file
39
frontend/stores/selectionRect.ts
Normal 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
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user