pub struct WindowAnim { /* private fields */ }Expand description
The animations one decorated window is running.
Focus and hover advance independently: a window can gain focus while the pointer leaves a button, and forcing them onto one timeline would make whichever started second jump.
Implementations§
Source§impl WindowAnim
impl WindowAnim
Sourcepub const fn new(focused: bool) -> Self
pub const fn new(focused: bool) -> Self
An animator settled at focused, with nothing hovered.
Settled, not animating toward it: a window that appears focused should be drawn focused, not fade in from unfocused on its first frame.
Sourcepub const fn retarget_focus(&mut self, focused: bool)
pub const fn retarget_focus(&mut self, focused: bool)
Aim at a new focus state.
Retargeting to what it is already aiming at does nothing — otherwise a caller that reports focus every frame would restart the timeline every frame and the window would never finish transitioning.
Sourcepub const fn retarget_hover(&mut self, hover: HoverButton)
pub const fn retarget_hover(&mut self, hover: HoverButton)
Aim at a new hovered button.
Moving between buttons restarts from zero on the new one rather than carrying the old one’s progress across: they are different highlights in different places, and a value carried over would make the new button appear already half-lit.
Sourcepub const fn snap(&mut self)
pub const fn snap(&mut self)
Jump to the targets, running nothing.
For a caller that wants the end state now — a window appearing, a theme with animations turned off, a session resuming.
Sourcepub fn tick(&mut self, dt: Duration, duration: Duration) -> bool
pub fn tick(&mut self, dt: Duration, duration: Duration) -> bool
Advance by dt, over a transition lasting duration.
Returns whether anything is still animating, which is what tells a caller to schedule another frame.
A zero duration snaps. That is not an edge case to tolerate but the
documented way to turn animations off — glass-minimal sets it — and
dividing by it instead would produce an infinity that the clamp turns
into an instant jump anyway, less legibly. A Duration cannot be
negative, so a caller converting
Theme::animation_duration_ms
must map a negative value to zero itself to get the same snap.
Sourcepub const fn is_animating(&self) -> bool
pub const fn is_animating(&self) -> bool
Whether anything is still moving.
Sourcepub const fn focus_progress(&self) -> f32
pub const fn focus_progress(&self) -> f32
How far through the focus transition, 0..=1.
Sourcepub const fn hover_progress(&self) -> f32
pub const fn hover_progress(&self) -> f32
How far through the hover transition, 0..=1.
Sourcepub const fn hover_painted(&self) -> HoverButton
pub const fn hover_painted(&self) -> HoverButton
Which button is being drawn highlighted.
Sourcepub const fn apply_to(&self, state: &mut WindowState)
pub const fn apply_to(&self, state: &mut WindowState)
Write the current progress into a state for the renderer.