Fixed flexbox layout bug when container size changes #1

Merged
megaSukura merged 8 commits from fix-flexbox into main 2025-04-20 16:08:06 +08:00
megaSukura commented 2025-04-19 19:02:01 +08:00 (Migrated from github.com)

Pull Request

Issue Fixed

There is a layout issue when the Flexbox changes size. The relevant script is as follows:

local main = basalt.getMainFrame()

local flexbox = main:addFlexbox({height = 20,width = 20}):setFlexDirection("column")

local button1 = flexbox:addButton({text = "add size"})
button1:onClick(function()
    flexbox:setHeight(flexbox:getHeight() + 1)
    flexbox:setWidth(flexbox:getWidth() + 1)
end):setFlexGrow(1)

local button2 = flexbox:addButton({text = "reduce size",background = colors.green})
button2:onClick(function()
    flexbox:setHeight(flexbox:getHeight() - 1)
    flexbox:setWidth(flexbox:getWidth() - 1)
end):setFlexGrow(1)

local button3 = flexbox:addButton({text = "last",background = colors.blue})
button3:onClick(function()

end):setFlexGrow(1)


basalt.run()

New Features

The issue has been fixed, and the following new features have been added:

  • flexAlignItems and flexCrossPadding on the cross axis
# Pull Request ## Issue Fixed There is a layout issue when the Flexbox changes size. The relevant script is as follows: ```lua local main = basalt.getMainFrame() local flexbox = main:addFlexbox({height = 20,width = 20}):setFlexDirection("column") local button1 = flexbox:addButton({text = "add size"}) button1:onClick(function() flexbox:setHeight(flexbox:getHeight() + 1) flexbox:setWidth(flexbox:getWidth() + 1) end):setFlexGrow(1) local button2 = flexbox:addButton({text = "reduce size",background = colors.green}) button2:onClick(function() flexbox:setHeight(flexbox:getHeight() - 1) flexbox:setWidth(flexbox:getWidth() - 1) end):setFlexGrow(1) local button3 = flexbox:addButton({text = "last",background = colors.blue}) button3:onClick(function() end):setFlexGrow(1) basalt.run() ``` ## New Features The issue has been fixed, and the following new features have been added: - `flexAlignItems` and `flexCrossPadding` on the `cross axis`
Sign in to join this conversation.
No description provided.