diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-03-09 19:00:53 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-03-09 19:15:31 +1100 |
| commit | 28d98f54ffe42f0b10971789214e765f2fae098c (patch) | |
| tree | 2c42d26e0142341c3da05120a219bccbd768a498 /src/components/TileTree.vue | |
| parent | 97f30117298686cb0b49df2e6633ba017b3e2547 (diff) | |
Add divs enclosing parent-area-using tiles
Diffstat (limited to 'src/components/TileTree.vue')
| -rw-r--r-- | src/components/TileTree.vue | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue index 5c3d08e..a772594 100644 --- a/src/components/TileTree.vue +++ b/src/components/TileTree.vue @@ -27,12 +27,14 @@ export default { let tree = { tolNode:tol, children:[], x:0, y:0, w:0, h:0, headerSz:0, + sideArea:{x:0, y:0, w:0, h:0, sweptLeft:false, extraSz:0}, }; function initTreeRec(tree, lvl){ if (lvl > 0) tree.children = tree.tolNode.children.map(tNode => initTreeRec({ tolNode: tNode, children: [], x:0, y:0, w:0, h:0, headerSz:0, + sideArea:{x:0, y:0, w:0, h:0, sweptLeft:false, extraSz:0}, }, lvl-1)); return tree; } @@ -78,13 +80,25 @@ export default { } }, applyLayout(layout, tree){ - //layout format: {x, y, w, h, headerSz, children:[layout1, ...], contentW, contentH, empSpc} + //layout format: {x, y, w, h, headerSz, children:[layout1, ...], contentW, contentH, empSpc, sideArea} tree.x = layout.x; tree.y = layout.y; tree.w = layout.w; tree.h = layout.h; tree.headerSz = layout.headerSz; layout.children.forEach((n,i) => this.applyLayout(n, tree.children[i])); + //handle case where leaf nodes placed in leftover space from parent-sweep + if (layout.sideArea){ + //add parent area coords + tree.sideArea = layout.sideArea; + //move leaf node children to parent area + tree.children.filter(n => n.children.length == 0).map(n => { + n.x += layout.sideArea.x; + n.y += layout.sideArea.y; + }); + } else { + tree.sideArea = {x:0, y:0, w:0, h:0, sweptLeft:false, extraSz:0}; + } } }, created(){ |
