Calculating a UI's size without rendering it
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
It would be cool if we were able to get a widgets size before actually rendering it. I know this is a fundamental limitation of immediate mode UIs, but it should be easily possible to do this, right? Basically we just make all of the calls except the ones that take any effect on the screen.
My situation is that I have a row of items with different sizes, and I want the entire row to have the same height. When I add the tallest item first, this works, because then the later elements know their height. But when the tallest element is not the first, then the first item will not know how tall it should be. So I would like to iterate through all elements before rendering them, to calculate their sizes and find the max height, then set use that height for all elements when rendering them.

The idea is basically to render to an offscreen buffer, just to get the final size of the `Ui`, without actually rendering anything. If there is some way to know if the `Ui` changed it would also be possible to cache something here, but I doubt that this will be possible without compromising developer experience.
Contributor guide
Research direction
The issue provides no files, tests, or entry points; begin by reviewing egui's layout and rendering paths against the proposed offscreen sizing approach. Done would require an agreed design and a demonstrated way to determine a row's maximum height before visible rendering, validated with the order-dependent example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100