Skip to content

Sizing-pass flag #4535

@emilk

Description

@emilk

Problem

The first frame we shown an Area or a Grid we only measure the size of everything, but don't show anything to the user. This the first frame becomes a size-measuring pass. This is a poor-mans two-pass mode.

A common problem is "How wide do we need to make this area"? (e.g. a menu).
We usually want to set a max width of e.g. 400 points, at which we should start wrapping.
But if we can keep things more narrow, that's better.

Now consider a widget that expands to fill its parent, e.g. a Separator.
It will the first frame expand to the full max width, and then the min width = max width, and so we will always expand to the maximum allowed with. This is bad, causing menus to become overly wide.

For more details, see #843

Solution

We set a simple boolean flag for the sizing pass.
Widgets that expand to fill the max_width would first check this flag, and if set, they would not expand, but only allocate the minimum size they actually need.
When the sizing pass finishes, we store the final size in the Area state (or whatever), and then next frame we have a properly sized area.

This flag would be passed down to child UIs.

Would close

Other related

Metadata

Metadata

Assignees

Labels

layoutRelated to widget layoutrerunDesired for Rerun.io

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions