From 96471325690118c6ae98ce85cc00818bdb63cf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Thu, 19 Jan 2023 00:27:38 +0000 Subject: [PATCH] "rectangles" property --- ui/src/components/rects/RectPad.vue | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ui/src/components/rects/RectPad.vue b/ui/src/components/rects/RectPad.vue index 5856515..35e4351 100644 --- a/ui/src/components/rects/RectPad.vue +++ b/ui/src/components/rects/RectPad.vue @@ -13,7 +13,7 @@ @dblclick.left="remove_rect" > @@ -56,7 +56,7 @@ export default class RectPad extends Vue { private dragging = false; private drag_rect?: Rectangle; private drag_origin = new Vector2D(); - private rectangles: Rectangle[] = []; + private _rectangles: Rectangle[] = []; private get preview_visible(): boolean { return this.drawing || this.dragging; @@ -69,14 +69,22 @@ export default class RectPad extends Vue { ).normalize(); } + public get rectangles(): Rectangle[] { + return this._rectangles; //.map((rect) => rect.normalize()); + } + + public set rectangles(rects: Rectangle[]) { + this._rectangles = rects; //.map((rect) => rect.normalize()); + } + private pop_rectangle(point: Vector2D): Rectangle | undefined { - const idx = this.rectangles.findIndex((rect) => rect.contains(point)); + const idx = this._rectangles.findIndex((rect) => rect.contains(point)); if (idx === -1) { return; } - return this.rectangles.splice(idx, 1)[0]; + return this._rectangles.splice(idx, 1)[0]; } private draw_start(event: MouseEvent) { @@ -100,7 +108,7 @@ export default class RectPad extends Vue { return; } - this.rectangles.push(this.preview_rectangle); + this._rectangles.push(this.preview_rectangle); } private drag_start(event: MouseEvent) { @@ -128,7 +136,7 @@ export default class RectPad extends Vue { } this.dragging = false; - this.rectangles.push(this.preview_rectangle); + this._rectangles.push(this.preview_rectangle); } private on_mousemove(event: MouseEvent) {