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