all working

This commit is contained in:
Michael Freno
2025-09-18 22:28:05 -04:00
parent c0684e88ab
commit 0380fb9fd2

View File

@@ -1118,15 +1118,20 @@ function Element:calculateAutoWidth()
end end
local totalWidth = width local totalWidth = width
local participatingChildren = 0
for _, child in ipairs(self.children) do for _, child in ipairs(self.children) do
local paddingAdjustment = (child.padding.left or 0) + (child.padding.right or 0) -- Skip explicitly absolute positioned children as they don't affect parent auto-sizing
local childWidth = child.width or child:calculateAutoWidth() if not child._explicitlyAbsolute then
local childOffset = childWidth + paddingAdjustment local paddingAdjustment = (child.padding.left or 0) + (child.padding.right or 0)
local childWidth = child.width or child:calculateAutoWidth()
local childOffset = childWidth + paddingAdjustment
totalWidth = totalWidth + childOffset totalWidth = totalWidth + childOffset
participatingChildren = participatingChildren + 1
end
end end
return totalWidth + (self.gap * #self.children) return totalWidth + (self.gap * participatingChildren)
end end
--- Calculate auto height based on children --- Calculate auto height based on children
@@ -1137,14 +1142,19 @@ function Element:calculateAutoHeight()
end end
local totalHeight = height local totalHeight = height
local participatingChildren = 0
for _, child in ipairs(self.children) do for _, child in ipairs(self.children) do
local paddingAdjustment = (child.padding.top or 0) + (child.padding.bottom or 0) -- Skip explicitly absolute positioned children as they don't affect parent auto-sizing
local childOffset = child.height + paddingAdjustment if not child._explicitlyAbsolute then
local paddingAdjustment = (child.padding.top or 0) + (child.padding.bottom or 0)
local childOffset = child.height + paddingAdjustment
totalHeight = totalHeight + childOffset totalHeight = totalHeight + childOffset
participatingChildren = participatingChildren + 1
end
end end
return totalHeight + (self.gap * #self.children) return totalHeight + (self.gap * participatingChildren)
end end
---@param newText string ---@param newText string