Skip to main content

AnimationScheduler

Struct AnimationScheduler 

Source
pub struct AnimationScheduler { /* private fields */ }
Expand description

Manages active animations and advances them each frame.

Implementations§

Source§

impl AnimationScheduler

Source

pub fn new() -> Self

Source

pub fn animate( &mut self, signal: &Signal<f32>, widget_id: WidgetId, target: f32, duration: Duration, easing: Easing, now: Instant, )

Start animating a Signal<f32> from its current value to target. If the signal is already being animated, the previous animation is replaced (the current in-flight value becomes the new start).

Source

pub fn animate_with_options( &mut self, signal: &Signal<f32>, widget_id: WidgetId, target: f32, duration: Duration, easing: Easing, frame_interval: Option<Duration>, epsilon: f32, max_duration: Option<Duration>, now: Instant, )

Source

pub fn animate_looping( &mut self, signal: &Signal<f32>, widget_id: WidgetId, start: f32, end: f32, period: Duration, easing: Easing, frame_interval: Option<Duration>, epsilon: f32, max_duration: Option<Duration>, now: Instant, )

Start a looping animation that cycles from start to end repeatedly. The signal resets to start each time it reaches end. Runs until cancelled.

Source

pub fn cancel(&mut self, signal: &Signal<f32>)

Cancel any active animation on the given signal.

Source

pub fn cancel_by_widget(&mut self, widget_id: WidgetId)

Cancel every animation whose driving widget matches widget_id.

Called when a widget is destroyed or rebuilt: the widget’s Signal<f32> clones in the scheduler would otherwise outlive the widget, continuing to tick against an orphaned signal whose observers no longer exist — silent CPU waste and, on rebuild, a second animation for the fresh signal stacking on top of the old.

Source

pub fn set_window_active(&mut self, active: bool, now: Instant)

Mark the owning window as active (focused-and-visible) or not.

Inactive: tick is a no-op; next_deadline returns None. On transition back to active, each animation’s start_time is rebased by the paused duration so the eased phase t is continuous — a 50%-through sweep resumes at 50%, not snapped to some other spot on the curve.

Source

pub fn is_window_active(&self) -> bool

Source

pub fn tick( &mut self, now: Instant, arena: &WidgetArena, paint_epoch: u64, ) -> bool

Advance all active animations to the given time. Returns true if any animation is still running and eligible to run next tick (caller should request another frame).

arena + paint_epoch gate per-widget visibility for looping animations only: a continuous spinner whose owner widget is dormant or hasn’t been painted in the most recent paint pass skips its tick. One-shot tweens are NOT visibility-gated — a widget that animates its own size from zero (e.g. Collapse growing from height=0 to natural) would otherwise be paused on the very tick that would make it visible, locking it in the invisible state forever. Pass paint_epoch == 0 to disable the gate entirely (headless tests that never call render()).

Source

pub fn has_active(&self) -> bool

Whether any animation is currently stored in the scheduler (ignores pause state — prefer has_running).

Source

pub fn has_running(&self) -> bool

Whether any animation is eligible to advance on the next tick: stored AND the window is active. Used by the idle-work predicates so a window-paused scheduler doesn’t keep the event loop in ControlFlow::WaitUntil.

This does NOT check per-widget visibility (we’d need the arena and the current paint epoch). An animation whose widget is offscreen is still reported here; the per-widget gate lives in next_deadline and tick directly.

Source

pub fn next_deadline( &self, arena: &WidgetArena, paint_epoch: u64, ) -> Option<Instant>

Earliest deadline at which a not-paused animation wants to tick. Returns None when the scheduler is window-paused, all (looping) animations are hidden, or there are no animations at all. One-shot tweens are NOT visibility-gated — see the matching note on tick.

Source

pub fn active_count(&self) -> usize

Number of active animations (for testing/debugging).

Trait Implementations§

Source§

impl Debug for AnimationScheduler

Source§

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

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

impl Default for AnimationScheduler

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> 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, 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, <T as TryFrom<U>>::Error>

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.