Fix gui.Stack expanding

This commit is contained in:
luk3yx 2023-02-09 11:08:00 +13:00
parent 451f679ddc
commit 5f2e601938
2 changed files with 18 additions and 4 deletions

View File

@ -320,10 +320,18 @@ local function expand(box)
(box_type == "padding" and box[1].expand) then
box.type = "container"
for _, node in ipairs(box) do
align_types[node.align_h or "auto"](node, "x", "w", box.w -
node.w - (node.padding or 0) * 2)
align_types[node.align_v or "auto"](node, "y", "h", box.h -
node.h - (node.padding or 0) * 2 - (node._padding_top or 0))
if not invisible_elems[node.type] then
local width, height = node.w or 0, node.h or 0
if node.type == "list" then
width = width * 1.25 - 0.25
height = height * 1.25 - 0.25
end
local padding_x2 = (node.padding or 0) * 2
align_types[node.align_h or "auto"](node, "x", "w", box.w -
width - padding_x2)
align_types[node.align_v or "auto"](node, "y", "h", box.h -
height - padding_x2 - (node._padding_top or 0))
end
end
return expand_child_boxes(box)
elseif box_type == "container" or box_type == "scroll_container" then

View File

@ -239,6 +239,9 @@ describe("Flow", function()
gui.Field{name = "5", label = "", align_v = "fill"},
gui.Label{label = "Test", align_h = "centre"},
gui.List{inventory_location = "a", list_name = "b", w = 2, h = 2},
gui.Style{selectors = {"test"}, props = {prop = "value"}},
}, [[
size[3.6,3.6]
field_close_on_enter[4;false]
@ -250,6 +253,9 @@ describe("Flow", function()
image_button[0.3,1.6;3,0.4;blank.png;;Test;;false]
image_button[0.3,1.6;3,0.4;blank.png;;;;false]
list[a;b;0.675,0.675;2,2]
style[test;prop=value]
]])
end)
end)