From c7db274b1aea73a78d0b80143352d8775ade8179 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 4 Jan 2021 13:46:39 -0600 Subject: [PATCH] updated components.lua --- src/ui/components.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ui/components.lua b/src/ui/components.lua index 8bb6c03..fcd8a36 100644 --- a/src/ui/components.lua +++ b/src/ui/components.lua @@ -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 -- 2.25.1