updated components.lua master
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 4 Jan 2021 19:46:39 +0000 (13:46 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 4 Jan 2021 19:46:39 +0000 (13:46 -0600)
src/ui/components.lua

index 8bb6c03a64f4d2acfdf3665eb9042edae1e4867b..fcd8a36a443ddcb14c0ba3f4ddf275d0c1675fca 100644 (file)
@@ -497,8 +497,6 @@ end
 
 local function_blocks_container = {}
 function function_blocks_container:make_tree(root)
-    print("Creating tree!", root)
-
        local funcs = {}
        for _, f in ipairs(self.children) do
                funcs[f.func.funcidx] = f
@@ -512,13 +510,20 @@ function function_blocks_container:make_tree(root)
     local have_added = {}
     local to_add     = {}
 
-    table.insert(to_add, { block = root, x = sx, y = sy })
+    table.insert(to_add, { block = root, x = sx, y = sy, depth = 1 })
+
+    local last_depth = 1
+    local x = sx
 
     while #to_add > 0 do
         local adding = to_add[1]
         table.remove(to_add, 1)
         table.insert(have_added, adding.block)
-        print("Processing", adding.block.func.funcidx)
+
+        if adding.depth ~= last_depth then
+            x = sx
+        end
+        last_depth = adding.depth
 
         adding.block.rect.x = adding.x
         adding.block.rect.y = adding.y
@@ -526,14 +531,14 @@ function function_blocks_container:make_tree(root)
         if adding.block.func.callees then
             local cc = #adding.block.func.callees
 
-            local x = adding.x
             for i, calls in revipairs(adding.block.func.callees) do
                 local b = funcs[calls]
                 if not table.contains(have_added, b) then
                     table.insert(to_add, {
                         block = b,
                         x = x,
-                        y = adding.y + adding.block.rect.h + padding
+                        y = adding.y + adding.block.rect.h + padding,
+                        depth = adding.depth + 1,
                     })
 
                     x = x + b.rect.w + padding