Set eframe to fit its content
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Is your feature request related to a problem? Please describe.**
Eframe uses a specific size on creation. I want to measure the size of the content and set the size accordingly.
**Describe the solution you'd like**
I've hacked up a solution which works for me on my application on my OS. I wish (at least some) features would be part of egui, so they could be tested for other systems and thus be more dependable.
**Describe alternatives you've considered**
Currently using a eframe means to set it to a guessed (hopefully reasonable) default size and let the user resize it.
**Additional context**
I haven't found an issue on this repo which would already deal with that.
I found some discussions:
- [Automatically set initial window size to fit contents
#2858](https://github.com/emilk/egui/discussions/2858) Shows a solution which works on MacOS using a window to calculate the inner size. It links to:
- [How to dynamically resize eframe window? #4329
](https://github.com/emilk/egui/discussions/4329) detailing how to change a eframe size after creation.
I'm running Linux (CachyOS) with Gnome 49.1 on Wayland. I need two update cycles to pre-render the GUI in a egui::window. Then one cycle to create a CenterPanel. Then a cycle to resize the CenterPanel:
- [Application with minimal example](https://github.com/PJaros/eframe-fit-content)
- [Application which uses it](https://github.com/PJaros/menu_pdf)
So I wish those two features:
- a way to calculate the inner size without a egui::window
- a way to resize a eframe with no need to use an additional update cycle
Contributor guide
Research direction
Start by reviewing eframe's sizing behavior alongside the linked discussions and minimal example, focusing on the egui::window and CenterPanel approaches described in the issue. Done means providing a dependable way to calculate content-driven inner size without an egui::window and resize eframe without an extra update cycle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100