-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ui::is_sizing_pass
for better size estimation of Area
s, and menus in particular
#4557
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emilk
commented
May 28, 2024
emilk
force-pushed
the
emilk/sizing-pass-flag
branch
2 times, most recently
from
May 28, 2024 12:20
9385170
to
a1d3c66
Compare
all available width
emilk
force-pushed
the
emilk/sizing-pass-flag
branch
from
May 28, 2024 19:04
a1d3c66
to
49191c0
Compare
emilk
changed the title
Better sizing pass for
Add May 29, 2024
Area
s, and menus in particularUi::is_sizing_pass
for better size estimation of Area
s, and menus in particular
hacknus
pushed a commit
to hacknus/egui
that referenced
this pull request
Oct 30, 2024
…enus in particular (emilk#4557) * Part of emilk#4535 * Closes emilk#3974 This adds a special `sizing_pass` mode to `Ui`, in which we have no centered or justified layouts, and everything is hidden. This is used by `Area` to use the first frame to measure the size of its contents so that it can then set the perfectly correct size the subsequent frames. For menus, where buttons are justified (span the full width), this finally the problem of auto-sizing. Before you would have to pick a width manually, and all buttons would expand to that width. If it was too wide, it looked weird. If it was too narrow, text would wrap. Now all menus are exactly the width they need to be. By default menus will wrap at `Spacing::menu_width`. This affects all situations when you have something that should be as small as possible, but still span the full width/height of the parent. For instance: the `egui::Separator` widget now checks the `ui.is_sizing_pass` flag before deciding on a size. In the sizing pass a horizontal separator is always 0 wide, and only in subsequent passes will it span the full width.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a special
sizing_pass
mode toUi
, in which we have no centered or justified layouts, and everything is hidden. This is used byArea
to use the first frame to measure the size of its contents so that it can then set the perfectly correct size the subsequent frames.For menus, where buttons are justified (span the full width), this finally the problem of auto-sizing. Before you would have to pick a width manually, and all buttons would expand to that width. If it was too wide, it looked weird. If it was too narrow, text would wrap. Now all menus are exactly the width they need to be. By default menus will wrap at
Spacing::menu_width
.This affects all situations when you have something that should be as small as possible, but still span the full width/height of the parent. For instance: the
egui::Separator
widget now checks theui.is_sizing_pass
flag before deciding on a size. In the sizing pass a horizontal separator is always 0 wide, and only in subsequent passes will it span the full width.