From 0fb594e3d24debe3758abd70d4e0234598e229ca Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sun, 13 Mar 2022 15:20:54 +1100
Subject: Attempt adding Coord and Dims types

---
 src/components/TileTree.vue | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

(limited to 'src/components/TileTree.vue')

diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index ce2688e..9fc053a 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -2,7 +2,7 @@
 import {defineComponent} from 'vue';
 import Tile from './Tile.vue';
 
-import {TolNode, TreeNode, LayoutNode} from '../types';
+import {TolNode, TreeNode, LayoutNode, Coord, Dims} from '../types';
 import {genLayout, layoutInfoHooks} from '../layout';
 //regarding importing a file f1.ts:
 	//using 'import f1.ts' makes vue-tsc complain, and 'import f1.js' makes vite complain
@@ -72,7 +72,7 @@ export default defineComponent({
 				nodeList[0].children = children;
 		},
 		tryLayout(){
-			let layout = genLayout(this.tree, 0, 0, this.width, this.height, true);
+			let layout = genLayout(this.tree, new Coord(), new Dims(this.width, this.height), true);
 			if (layout == null){
 				console.log('Unable to layout tree');
 				return false;
@@ -82,10 +82,8 @@ export default defineComponent({
 			}
 		},
 		applyLayout(layout: LayoutNode, tree: TreeNode){
-			tree.x = layout.x;
-			tree.y = layout.y;
-			tree.w = layout.w;
-			tree.h = layout.h;
+			tree.pos = layout.pos;
+			tree.dims = layout.dims;
 			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
@@ -94,8 +92,8 @@ export default defineComponent({
 				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;
+					n.pos.x += layout.sideArea!.pos.x;
+					n.pos.y += layout.sideArea!.pos.y;
 				});
 			} else {
 				tree.sideArea = null;
-- 
cgit v1.2.3

