mirror of
https://github.com/danbulant/cushy
synced 2026-06-20 06:51:07 +00:00
OverlayLayer::dismiss_all
This commit is contained in:
parent
a63af0f9de
commit
74034760ce
2 changed files with 15 additions and 0 deletions
|
|
@ -237,6 +237,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `ModifiersExt` is an extension trait for winit's `Modifiers` and
|
||||
`ModifiersState` types. This trait adds helpers for dealing with
|
||||
platform-specific meanings for keyboard modifiers.
|
||||
- `OverlayLayer::dismiss_all()` dismisses all overlays immediately.
|
||||
|
||||
[plotters]: https://github.com/plotters-rs/plotters
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,20 @@ impl OverlayLayer {
|
|||
show_animation: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Dismisses all currently presented overlays.
|
||||
pub fn dismiss_all(&self) {
|
||||
let mut state = self.state.lock();
|
||||
state.hovering = None;
|
||||
let removed = state.overlays.drain().collect::<Vec<_>>();
|
||||
state.new_overlays = 0;
|
||||
drop(state);
|
||||
|
||||
// Since overlays contain references back to this structure, we need to
|
||||
// ensure their drop implementations happen after we've dropped our
|
||||
// lock.
|
||||
drop(removed);
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for OverlayLayer {
|
||||
|
|
|
|||
Loading…
Reference in a new issue