-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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
- egui menus: remember size from previous frame #3974
- ComboBox menu doesn't report its actual size to its closure #4452
- All UI containers should ideally define full span ranges themselves rerun-io/rerun#6246