Skip to content

Fix issues with desired size system#120640

Open
StarryWorm wants to merge 2 commits into
godotengine:masterfrom
StarryWorm:my-most-desired
Open

Fix issues with desired size system#120640
StarryWorm wants to merge 2 commits into
godotengine:masterfrom
StarryWorm:my-most-desired

Conversation

@StarryWorm

@StarryWorm StarryWorm commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

Fixes the issue whereby a Label using custom_maximum_size instead of custom_minimum_size to define its behavior would not expand vertically when shrunk horizontally whilst in autowrapping mode

Before After
image image

Test Project (from #119325):
no-clip-label-mrp.zip

Fixes the issue whereby layout Container types, namely BoxContainer, GridContainer, and FlowContainer, would not allocate size to their children that have a desired size greater than their minimum size.

Layout computation flow:

  1. Give each child its minimum size
  2. From the remaining space, distribute to children with a desired size greater than their minimum size based on the ratio of their desired sizes (i.e. a child who desires twice as much space as another will get twice as much, regardless of how much they end up getting).
  3. If any, from the remaining space, distribute to children with the SIZE_EXPAND flag based on their stretch ratios.

Step 2 is new, everything else stays unchanged.
In the case of FlowContainer, this process is actually much simpler, as we can just swap the desired size in for the minimum size, and then trim it back if there isn't enough space to fit it alone on a line/column.

Test Projects:

  1. For a simple Label (from BoxContainer, GridContainer, and FlowContainer don't respect their children's desired sizes without SIZE_EXPAND flag #119346): container-desired-sizes-mrp.zip
  2. For a layout with SIZE_EXPAND child: respect-desired-sizes-mrp.zip

Additional information

Bundled as a single PR since it's all related to the same system. Split commits for now, can squash if preferred.

Discovered this actually didn't need a more thorough rewrite of the sizing system, so getting it out now for maybe 4.7.1 cherrypicking.

@StarryWorm StarryWorm requested a review from a team as a code owner June 25, 2026 14:21
@YeldhamDev YeldhamDev added bug topic:gui cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release labels Jun 25, 2026
@YeldhamDev YeldhamDev added this to the 4.8 milestone Jun 25, 2026
@StarryWorm

Copy link
Copy Markdown
Contributor Author

It appears this also fixes #120099, want someone else to double-check before I mark it as such in PR description

Make `GridContainer` respect desired sizes
Make `BoxContainer` respect desired sizes
Make `FlowContainer` respect desired sizes

@YeldhamDev YeldhamDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine and fixes the issues. But I would still like a second review for this.

@KoBeWi KoBeWi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm it fixes the linked issues. The code seems fine overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release regression topic:gui

Projects

None yet

3 participants