pub struct OverlayState { /* private fields */ }Expand description
Owns overlay lifecycle, animation progress, and the computed inner area.
§State machine
Closed ──open()──▸ Opening ──tick──▸ Open
▴ │
└──tick──◂ Closing ◂──close()────────┘With default duration (zero), open()/close() transition instantly.
Set with_duration for animated transitions.
Interrupting mid-animation reverses from the current progress.
Implementations§
Source§impl OverlayState
impl OverlayState
pub fn new() -> Self
pub fn with_duration(self, duration: Duration) -> Self
pub fn with_easing(self, easing: Easing) -> Self
pub fn open(&mut self)
pub fn close(&mut self)
pub fn toggle(&mut self)
Sourcepub fn tick(&mut self, elapsed: Duration)
pub fn tick(&mut self, elapsed: Duration)
Advance animation by elapsed time. No-op when fully open, closed, or duration is zero.
pub fn is_open(&self) -> bool
pub fn is_closed(&self) -> bool
pub fn is_animating(&self) -> bool
Sourcepub fn overlay_rect(&self) -> Option<Rect>
pub fn overlay_rect(&self) -> Option<Rect>
Full overlay bounding rect, set during render. None when closed.
Use this for hit-testing (e.g. click-outside-to-dismiss):
ⓘ
if let Some(rect) = state.overlay_rect() {
if !rect.contains(click_position) {
state.close();
}
}Sourcepub fn inner_area(&self) -> Option<Rect>
pub fn inner_area(&self) -> Option<Rect>
Region available for body content (inside block chrome), set during render.
None when closed.
Trait Implementations§
Source§impl Clone for OverlayState
impl Clone for OverlayState
Source§fn clone(&self) -> OverlayState
fn clone(&self) -> OverlayState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OverlayState
impl Debug for OverlayState
Auto Trait Implementations§
impl Freeze for OverlayState
impl RefUnwindSafe for OverlayState
impl Send for OverlayState
impl Sync for OverlayState
impl Unpin for OverlayState
impl UnsafeUnpin for OverlayState
impl UnwindSafe for OverlayState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more