-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Nested overlays #1719
Nested overlays #1719
Conversation
I'm getting a layout related panic (unwrap) in the Edit: Removing all |
e4e6c50
to
01fb0b5
Compare
native/src/overlay/nested.rs
Outdated
if matches!(status, event::Status::Ignored) { | ||
element.on_event( | ||
event, | ||
layout, | ||
cursor_position, | ||
renderer, | ||
clipboard, | ||
shell, | ||
) | ||
} else { | ||
status | ||
} |
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.
Still need to encode cursor availability here when the overlay a layer higher is_over
. I've handled this on draw
already.
I tried updating it here, but there was an issue in the modal
example because of how pick_list
handles mouse clicks on it's overlay menu. It doesn't capture the event when clicked in the overlay, and instead lets the base widget handle "closing" and publishing to shell the selection.
This is an issue because then the nested pick_list
menu
overlay (higher layer) reports is_over
, but doesn't capture the event. So if we set cursor to (-1, -1)
, the "modal" overlay will think it's clicked outside and close, when we only want the pick_list
to close.
I think we need to refactor pick_list
to "capture" the mouse click in the overlay menu.
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've resolved this with a617f3a and 4d439e4.
You can compare the behavior prior to a617f3a on modal
example. If you select the middle picklist option over the text input, the text input focuses after selecting the option.
After a617f3a, the undesired behavior mentioned above occurs (modal closes when clicking outside menu bounds / onto modal).
After 4d439e4, the picklist menu now properly captures the status of the event in the overlay when an option is selected. Everything now works as expected.
I think we can just naively store the overlay element of the ouroboros builders tail field for the lazy widgets in a Edit: This seems to have worked like a charm: 5283a47. I tested by wrapping the I had to |
Just to give an update here: I have plans to tackle proper cursor availability soon, and this is waiting for that. |
Nested doesn't need to implement Overlay trait, it can be be used mutably in user interface so we don't need interior mutability.
5283a47
to
87db76a
Compare
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.
Awesome! Thanks 🥳 This is a huge win.
I have rebased on top of master
and everything seems to be working. Hopefully I didn't break anything!
Looks good to me and modal example is still working 👍 Thanks! |
@tarkah As you said "Nested is only public to the crate and only meant to be used as the root overlay used by the user interface" I wonder why is it used in |
This implements a new overlay which allows for nesting. It's fairly inefficient as it calls
Overlay::overlay
within every method, but this reduces complexity as dealing w/ lifetimes here will be really rough.The nice part is this doesn't touch the
UserInterface
code at all except to wrap the root overlay into aNested
.Nested
is only public to the crate and only meant to be used as the root overlay used by the user interface. This means that the layout caching done in user interface works for theNested
layout as well.I haven't implemented the nested
Overlay::overlay
on any of thelazy
overlay implementations yet, but I can implement if we feel this is a good approach.If approved, we can rebase #1692 as that should now work w/ this.
simplescreenrecorder-2023-02-18_13.53.33.mp4