Pyroxenium / Basalt

A UI Framework for CC:Tweaked
MIT License
194 stars 38 forks source link

bug: parent.w does'nt take in account flex-grow #120

Open ascpial opened 3 months ago

ascpial commented 3 months ago

Describe the bug

When an object is marked in a flexbox with flexgrow, the children of that object will not update parent.w accordingly.

To Reproduce

Steps to reproduce the behavior: Launch the code:

local basalt = require("basalt")

local main = basalt.createFrame()

local flex = main:addFlexbox()
    :setDirection("row"):setWrap("wrap")
    :setSize("parent.w-2", "parent.h-2")
    :setPosition(2, 2)
    :setBackground(false)

local subframe = flex:addFrame():setSize(20, 5)
    :setFlexBasis(20):setFlexGrow(1)
    :setBackground(colors.white)
subframe:addLabel():setText("A"):setPosition("parent.w", 2):setTextAlign("right"):setForeground(colors.gray)

basalt.autoUpdate()

Actual behaviour

Expected behavior

The A label should align at the right of the parent

Excpected behaviour

Checklist

ascpial commented 3 months ago

Note: this breaks an example in the documentation

Expected: image

Reality: image

ascpial commented 3 months ago

I believe this bug has been introduced by this commit.

In the child function, :getSize() and other getters should return by default the base width and height.