aboutsummaryrefslogtreecommitdiff
path: root/src/components/TileTree.vue
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-03-13 21:49:13 +1100
committerTerry Truong <terry06890@gmail.com>2022-03-13 21:49:21 +1100
commitfecec836f9c5bca72619931d0522f42f67080534 (patch)
tree55798031f4b3de7d8afe8b76c65f43e755107ea3 /src/components/TileTree.vue
parent4ae50f4abef0241d6517645ada0b28ed8d1103ee (diff)
Use 2-element arrays to represent x-y and width-height pairs
Diffstat (limited to 'src/components/TileTree.vue')
-rw-r--r--src/components/TileTree.vue12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index e9c8c93..ce3507d 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -73,7 +73,7 @@ export default defineComponent({
nodeList[0].children = children;
},
tryLayout(){
- let newLayout = genLayout(this.layoutTree, 0, 0, this.width, this.height, true);
+ let newLayout = genLayout(this.layoutTree, [0,0], [this.width,this.height], true);
if (newLayout == null){
console.log('Unable to layout tree');
return false;
@@ -83,10 +83,8 @@ export default defineComponent({
}
},
applyLayout(newLayout: LayoutNode, layoutTree: LayoutNode){
- layoutTree.x = newLayout.x;
- layoutTree.y = newLayout.y;
- layoutTree.w = newLayout.w;
- layoutTree.h = newLayout.h;
+ layoutTree.pos = newLayout.pos;
+ layoutTree.dims = newLayout.dims;
layoutTree.headerSz = newLayout.headerSz;
newLayout.children.forEach((n,i) => this.applyLayout(n, layoutTree.children[i]));
//handle case where leaf nodes placed in leftover space from parent-sweep
@@ -95,8 +93,8 @@ export default defineComponent({
layoutTree.sepSweptArea = newLayout.sepSweptArea;
//move leaf node children to parent area
layoutTree.children.filter(n => n.children.length == 0).map(n => {
- n.x += newLayout.sepSweptArea!.x;
- n.y += newLayout.sepSweptArea!.y;
+ n.pos[0] += newLayout.sepSweptArea!.pos[0],
+ n.pos[1] += newLayout.sepSweptArea!.pos[1]
});
} else {
layoutTree.sepSweptArea = null;