Skip to main content

WindowAnim

Struct WindowAnim 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn is_animating(&self) -> bool

Whether anything is still moving.

Source

pub const fn focus_progress(&self) -> f32

How far through the focus transition, 0..=1.

Source

pub const fn hover_progress(&self) -> f32

How far through the hover transition, 0..=1.

Source

pub const fn hover_painted(&self) -> HoverButton

Which button is being drawn highlighted.

Source

pub const fn apply_to(&self, state: &mut WindowState)

Write the current progress into a state for the renderer.

Trait Implementations§

Source§

impl Clone for WindowAnim

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WindowAnim

Source§

impl Debug for WindowAnim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowAnim

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.