Skip to content
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

egui menus: remember size from previous frame #3974

Closed
emilk opened this issue Feb 5, 2024 · 0 comments · Fixed by #4557
Closed

egui menus: remember size from previous frame #3974

emilk opened this issue Feb 5, 2024 · 0 comments · Fixed by #4557
Assignees
Labels
egui rerun Desired for Rerun.io

Comments

@emilk
Copy link
Owner

emilk commented Feb 5, 2024

egui menus use a justified layout, so that buttons fill the full width.
This means we currently have to pick a width up front and then fit all buttons to that.

It would be nicer to be able to dynamically size the menu based on the contents in the first frame.

@emilk emilk added egui rerun Desired for Rerun.io labels Feb 5, 2024
@emilk emilk added this to the Next Major Release milestone Feb 5, 2024
emilk added a commit to rerun-io/rerun that referenced this issue Feb 5, 2024
### What

Show `Color` instead of `rerun.components.Color`


![image](https://github.com/rerun-io/rerun/assets/1148717/d1e6bbf0-6126-4021-9f3a-2d2ac130d148)

The width is unnecessarily wide, but thats's something that I will punt
on for now (requires some menu memory in egui:
emilk/egui#3974).

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5037/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5037/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5037/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/5037)
- [Docs
preview](https://rerun.io/preview/2b2b8ad07179a57b58610587568973a0a9aacab4/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/2b2b8ad07179a57b58610587568973a0a9aacab4/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
@emilk emilk self-assigned this May 27, 2024
emilk added a commit that referenced this issue May 29, 2024
…enus in particular (#4557)

* Part of #4535
* Closes #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.
hacknus pushed a commit to hacknus/egui that referenced this issue 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
Labels
egui rerun Desired for Rerun.io
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant