-
Notifications
You must be signed in to change notification settings - Fork 1.9k
⚠️ Improved menu based on egui::Popup
#5716
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
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5716-lucaspopup-based-menu |
e6cf98d
to
0109e35
Compare
0109e35
to
b9c1a1f
Compare
egui::Popup
egui::Popup
…enu and deprecate old menu
# Conflicts: # crates/egui/src/containers/popup.rs # crates/egui/src/containers/window.rs # crates/egui/src/response.rs # crates/egui/src/ui.rs # crates/egui/src/ui_builder.rs # crates/egui_demo_lib/src/demo/context_menu.rs # crates/egui_demo_lib/src/demo/demo_app_windows.rs # crates/egui_demo_lib/src/demo/popups.rs
|
||
let inner = Popup::menu(&button_response) | ||
.id(popup_id) | ||
.style(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set the menu styles for the ComboBox? I'm overwriting this here since this is how it was before, but I think the menu styles would look nice here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question 🤔 If so I think we save it for another PR
ui.hyperlink_to( | ||
egui::RichText::new("🦋").size(font_size), | ||
"https://bsky.app/profile/ernerfeldt.bsky.social", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just have to wait for🐛...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would be a fun way to display the options, but it seems like the readability suffers a bit. Should I change it?
… Never close menu when clicking submenu buttons. Add tests.
8c9b953
to
a312478
Compare
@crumblingstatue good catch. I want to support opening multiple/nested popups which should fix this. But I'll implement that in a separate PR, since this one is already so big. |
Breaking changes: - When using the Memory::popup state, it's now required to call keep_popup_open each frame or the popup will close. - Usually handled by the `Popup` struct, but required for custom popups using the state in `Memory` directly ----- If a popup is abandoned `Memory::popup` would remain `Some`. This is problematic if, for example, you have logic that checks `is_any_popup_open`. This PR adds a new requirement for popups keeping their open state in `Memory::popup`. They must call `Memory::keep_popup_open` as long as they are being rendered. The recent changes in #5716 make this easy to implement. Supersedes #4697 which had an awkward implementation These two videos show a case where a context menu was open when the underlying widget got removed. Before (`any_popup_open` remains `true`)  After  * Closes #3657 * [x] I have followed the instructions in the PR template
### Related ### What I was curious how my work on egui [menus](emilk/egui#5716) and [popups](emilk/egui#5713) would work in rerun, so I gave it a try. ### Findings so far - ~The new tooltip positioning works well unless we scroll in the scroll area. Maybe we should intersect the widget rect with the clip rect.~ Fixed! https://github.com/user-attachments/assets/54e7ffb1-f0a9-4f2d-8776-e0bea8777903
Continuation of emilk#5713 **Silently breaking changes:** - Menus now close on click by default, this is configurable via `PopupCloseBehavior` **Additional additions:** - `Button::right_text` - `StyleModifier` This is a rewrite of the egui menus, with the following goals: - submenu buttons should work everywhere, in a popup, context menu, area, in some random Ui - remove the menu state from Ui - should work just like the previous menu - ~proper support for keyboard navigation~ - It's better now but requires further work to be perfect - support `PopupCloseBehavior` * Closes emilk#4607 * [x] I have followed the instructions in the PR template
Breaking changes: - When using the Memory::popup state, it's now required to call keep_popup_open each frame or the popup will close. - Usually handled by the `Popup` struct, but required for custom popups using the state in `Memory` directly ----- If a popup is abandoned `Memory::popup` would remain `Some`. This is problematic if, for example, you have logic that checks `is_any_popup_open`. This PR adds a new requirement for popups keeping their open state in `Memory::popup`. They must call `Memory::keep_popup_open` as long as they are being rendered. The recent changes in emilk#5716 make this easy to implement. Supersedes emilk#4697 which had an awkward implementation These two videos show a case where a context menu was open when the underlying widget got removed. Before (`any_popup_open` remains `true`)  After  * Closes emilk#3657 * [x] I have followed the instructions in the PR template
Continuation of #5713
Silently breaking changes:
PopupCloseBehavior
Additional additions:
Button::right_text
StyleModifier
This is a rewrite of the egui menus, with the following goals:
proper support for keyboard navigationPopupCloseBehavior