margin
This commit is contained in:
19
FlexLove.lua
19
FlexLove.lua
@@ -574,7 +574,7 @@ function Window:layoutChildren()
|
||||
goto continue
|
||||
end
|
||||
if self.flexDirection == FlexDirection.VERTICAL then
|
||||
child.x = currentPos
|
||||
child.x = currentPos + self.mx
|
||||
child.y = 0
|
||||
|
||||
-- Apply alignment to vertical axis (alignItems)
|
||||
@@ -599,9 +599,9 @@ function Window:layoutChildren()
|
||||
child.height = self.height
|
||||
end
|
||||
|
||||
currentPos = currentPos + (child.width or 0) + self.gap
|
||||
currentPos = currentPos + (child.width or 0) + self.gap + self.mx * 2
|
||||
else
|
||||
child.y = currentPos
|
||||
child.y = currentPos + self.my
|
||||
-- Apply alignment to horizontal axis (alignItems)
|
||||
if self.alignItems == AlignItems.FLEX_START then
|
||||
--nothing, currentPos is all
|
||||
@@ -624,7 +624,7 @@ function Window:layoutChildren()
|
||||
child.width = self.width
|
||||
end
|
||||
|
||||
currentPos = currentPos + (child.height or 0) + self.gap
|
||||
currentPos = currentPos + (child.height or 0) + self.gap + self.my * 2
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
@@ -815,7 +815,8 @@ function Window:calculateAutoWidth()
|
||||
end
|
||||
end
|
||||
|
||||
self.width = maxWidth + (self.px * 2)
|
||||
-- Add window's own px padding and mx margins to the final width
|
||||
self.width = maxWidth + (self.px * 2) + (self.mx * 2)
|
||||
end
|
||||
|
||||
--- Calculate auto height based on children
|
||||
@@ -839,8 +840,8 @@ function Window:calculateAutoHeight()
|
||||
end
|
||||
end
|
||||
|
||||
-- Add window's own py padding to the final height
|
||||
self.height = maxHeight + (self.py * 2)
|
||||
-- Add window's own py padding and my margins to the final height
|
||||
self.height = maxHeight + (self.py * 2) + (self.my * 2)
|
||||
end
|
||||
|
||||
--- Update window size to fit children automatically
|
||||
@@ -1101,8 +1102,8 @@ end
|
||||
function Button:updateText(newText, autoresize)
|
||||
self.text = newText or self.text
|
||||
if autoresize then
|
||||
self.width = self:calculateTextWidth() + self.px
|
||||
self.height = self:calculateTextHeight() + self.py
|
||||
self.width = self:calculateTextWidth() + (self.px * 2)
|
||||
self.height = self:calculateTextHeight() + (self.py * 2)
|
||||
end
|
||||
|
||||
-- If autosizing is enabled, recalculate size after text update
|
||||
|
||||
Reference in New Issue
Block a user