pub struct AnimationManager<K: Eq + Hash + Copy> { /* private fields */ }Expand description
Central, Qt-style animation driver, generic over any hashable key type so it can be reused outside of any specific GUI framework. Callers never own a timer themselves; they only report their current target value and the manager owns the entire lifecycle (starting, easing, retargeting, finishing).
Implementations§
Source§impl<K: Eq + Hash + Copy> AnimationManager<K>
impl<K: Eq + Hash + Copy> AnimationManager<K>
pub fn set_target( &mut self, key: K, target: AnimValue, transition: Option<Transition>, )
Sourcepub fn set_color_target(
&mut self,
key: K,
target: AnimValue,
transition: Option<Transition>,
)
pub fn set_color_target( &mut self, key: K, target: AnimValue, transition: Option<Transition>, )
Like set_target, but blends the transition using premultiplied
alpha - use this when target packs an RGBA color, so a
transparent endpoint’s meaningless RGB doesn’t leak into the blend
as a visible flash partway through the fade.
Sourcepub fn tick(&mut self, dt: Duration)
pub fn tick(&mut self, dt: Duration)
Advances every active transition by one frame’s delta time. Call exactly once per frame, before layout/paint.
Sourcepub fn value(&self, key: K) -> Option<AnimValue>
pub fn value(&self, key: K) -> Option<AnimValue>
Current (possibly mid-transition) value for key, or None once
the transition has settled - callers should fall back to their
own resolved target value in that case.
Sourcepub fn active_keys(&self) -> impl Iterator<Item = &K>
pub fn active_keys(&self) -> impl Iterator<Item = &K>
Iterates the keys of every animation currently mid-transition, letting callers check what is animating instead of only whether anything is - e.g. to skip layout work for animations that only affect paint (colors, opacity) and not the box model.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether any animation is currently in flight across all keys. Useful to decide whether the render loop needs to keep polling for frames.