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

Add support for modal windows to re_ui and use it for the Space View entity picker #4577

Merged
merged 7 commits into from
Dec 19, 2023

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Dec 18, 2023

What

Since egui doesn't have support for modal windows yet (emilk/egui#686), we rolled our own for the Space View entity picker ("Add/remove entities"). This PR abstracts the modal creation code into a dedicated feature in re_ui, and use that abstraction for the space view entity picker.

The new re_ui::modal has support for two aspects of modal window management:

  • The modal window itself (re_ui::modal::Modal), which handles dimming the background, a close button, and exiting with ESC and/or clicking outside of the window.
  • The handling of the modal window (re_ui::modal::ModalHandler). The Modal struct should be kept only while the modal is actually shown, so it's typically held in and Option<Modal>. ModalHandler implements the house keeping of populating the Option when the modal must be displayed, and dropping it when the modal is closed.

Note: with this PR, the modals are now properly centred, although erroneous centring behaviour might happen that require deleting your app.ron. This will eventually be fixed with a new egui release that includes emilk/egui#3721

Usage:

image image

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@abey79 abey79 added ui concerns graphical user interface 🚜 refactor Change the code, not the functionality include in changelog labels Dec 18, 2023
Include a `ModelHandler` helper object.
Rebase fix to using modal in entity picker
@abey79 abey79 force-pushed the antoine/re-ui-modal branch from 5000f73 to 3e8a3ad Compare December 19, 2023 07:40
@Wumpf Wumpf self-requested a review December 19, 2023 08:54
@Wumpf
Copy link
Member

Wumpf commented Dec 19, 2023

was hoping this also fixes the bug of modal windows being off-center. Alas it does not
image

@Wumpf
Copy link
Member

Wumpf commented Dec 19, 2023

Looks whatever prevented pinning the dialog to the middle got fixed \o/ - plz have a look at d9bef9d

Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful!

crates/re_viewport/src/space_view_entity_picker.rs Outdated Show resolved Hide resolved
crates/re_ui/src/modal.rs Show resolved Hide resolved
@abey79
Copy link
Member Author

abey79 commented Dec 19, 2023

Looks whatever prevented pinning the dialog to the middle got fixed \o/ - plz have a look at d9bef9d

This is still not working for me, ie. it centres the top-left corner instead of the center of the window as specified by the pivot function.

Edit: I've been it by emilk/egui#3721

@abey79 abey79 merged commit cde58b1 into main Dec 19, 2023
41 checks passed
@abey79 abey79 deleted the antoine/re-ui-modal branch December 19, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🚜 refactor Change the code, not the functionality ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants