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 Modal and Memory::set_modal_layer #5358

Merged
merged 14 commits into from
Nov 28, 2024
Merged

Add Modal and Memory::set_modal_layer #5358

merged 14 commits into from
Nov 28, 2024

Conversation

lucasmerlin
Copy link
Collaborator

@lucasmerlin lucasmerlin commented Nov 8, 2024

This adds modals to egui.
This PR

  • adds a new Modal struct
  • adds Memory::set_modal_layer to limit focus to a layer and above (used by the modal struct, but could also be used by custom modal implementations)
  • adds Memory::allows_interaction to check if a layer is behind a modal layer, deprecating Layer::allows_interaction

Current problems:

Possible future improvements:

  • The titlebar from window should be made into a separate widget and added to the modal
  • The state whether the modal is open should be stored in egui (optionally), similar to popup and menu. Ideally before this we would refactor popup state to unify popup and menu

@lucasmerlin lucasmerlin changed the title Add modal Add Modal and Memory::set_modal_layer Nov 8, 2024
@lucasmerlin lucasmerlin marked this pull request as draft November 8, 2024 10:30
Copy link

github-actions bot commented Nov 8, 2024

Preview available at https://egui-pr-preview.github.io/pr/5358-lucas/modal
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin lucasmerlin force-pushed the lucas/modal branch 2 times, most recently from a985092 to bf4d7df Compare November 14, 2024 13:12
@lucasmerlin lucasmerlin added feature New feature or request egui labels Nov 14, 2024
@lucasmerlin lucasmerlin marked this pull request as ready for review November 14, 2024 14:08
Copy link
Owner

@emilk emilk 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/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui/src/containers/modal.rs Outdated Show resolved Hide resolved
crates/egui_demo_lib/src/demo/modals.rs Outdated Show resolved Hide resolved
crates/egui_demo_lib/src/demo/modals.rs Outdated Show resolved Hide resolved
crates/egui_demo_lib/src/demo/modals.rs Outdated Show resolved Hide resolved
crates/egui_demo_lib/src/demo/modals.rs Outdated Show resolved Hide resolved
@lucasmerlin lucasmerlin merged commit 10791cc into master Nov 28, 2024
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal dialogs
2 participants