Skip to content

Fix desired size space allocation not respecting minimum sizes correctly#120913

Open
StarryWorm wants to merge 1 commit into
godotengine:masterfrom
StarryWorm:this-is-starting-to-feel-like-im-a-shadok
Open

Fix desired size space allocation not respecting minimum sizes correctly#120913
StarryWorm wants to merge 1 commit into
godotengine:masterfrom
StarryWorm:this-is-starting-to-feel-like-im-a-shadok

Conversation

@StarryWorm

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

In that PR, I made BoxContainer and GridContainer (and FlowContainer, but that one isn't bugged) allocate space to children whose desired sizes were greater than their minimum sizes.
As described in the PR, the flow would go:

  1. Give each child its minimum size
  2. From the remaining space, distribute to children with a desired size
  3. If any, from the remaining space, distribute to children with the SIZE_EXPAND flag

The problem is, in both cases, the "remaining space" computed for step 3, which I used for step 2, also includes the space occupied by the minimum size of the children who have the SIZE_EXPAND flag. This is done such that their final sizes are computed irrespective of their minimum sizes, and only take into account the stretch ratios.
However, using that in step 2 resulted in the children in step 2 overallocating, using the minimum size of the expanding children as free space to stretch into. This is completely erroneous and results in the step 2 children taking up more space than is available.

The images below use HBoxContainer, the project has both, but they look the same, so I only put images for one.
Before:
image

After PR:
image

Project:
respect-desired-sizes-mrp.zip

Additional information

The project additionally contains the previous tests from #120640 to ensure no regressions against that PR.

This bug slipped through because of a lack of test coverage for the new system, which I should have added earlier. I will work to expand test coverage for these containers so that this kind of oversight does not happen again.

@StarryWorm StarryWorm requested a review from a team as a code owner July 3, 2026 21:45
@YeldhamDev YeldhamDev added this to the 4.8 milestone Jul 3, 2026

@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.

Fixes the issue. And indeed, GUI tests for sizing would help a lot in minimizing those regressions.

@YeldhamDev YeldhamDev added the cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release label Jul 3, 2026
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

Development

Successfully merging this pull request may close these issues.

2 participants