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

Open
opened 2024-08-25 23:41:23 +08:00 by ascpial · 2 comments
ascpial commented 2024-08-25 23:41:23 +08:00 (Migrated from github.com)

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

  • I am running the latest version.
**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: ```lua 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](https://github.com/user-attachments/assets/4fab27b4-7787-4c80-82ba-8fc6bffd545a) **Expected behavior** The A label should align at the right of the parent ![Excpected behaviour](https://github.com/user-attachments/assets/15052d13-7be2-49bc-b0c0-1adeb822252e) **Checklist** - [x] I am running the latest version.
ascpial commented 2024-08-25 23:46:18 +08:00 (Migrated from github.com)

Note: this breaks an example in the documentation

Expected:
image

Reality:
image

Note: this breaks an example in [the documentation](https://basalt.madefor.cc/#/objects/Flexbox?id=another-example) Expected: ![image](https://github.com/user-attachments/assets/5bf469ae-4871-4438-8a78-1b7f942b8f79) Reality: ![image](https://github.com/user-attachments/assets/c6a8f4f8-71d6-41ca-b5ee-acfcd7e5b694)
ascpial commented 2024-08-26 01:39:41 +08:00 (Migrated from github.com)

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.

I believe this bug has been introduced by [this commit](https://github.com/Pyroxenium/Basalt/commit/8168fa4465f3022cc2e3ff02fa5533b9d31fe548#diff-7baef59667eaf605f2b332644d18279e9d9a17737da64ec4523e035f4a9b1689). In the child function, [`:getSize()`](https://github.com/Pyroxenium/Basalt/blob/8dd8e63d21752f2fe621b04b9db0aeb155fedf0d/Basalt/objects/Flexbox.lua#L38) and other getters should return by default the base width and height.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GitHub/Basalt#120
No description provided.