pub struct ObjectAnims { /* private fields */ }Expand description
Walker and id allocator for object-bound animations (LPAR-06 §6).
ObjectAnims is stateless except for its id counter. The animation entries
themselves live on the target ObjectNode nodes. On each
tick, ObjectAnims depth-first walks the live tree,
advances each entry, invokes apply callbacks, pushes dirty rects to the
caller-supplied sink, and removes completed entries (firing their
on_complete hooks).
§no_std + alloc
Requires alloc, consistent with ANIM-00 Animations.
Implementations§
Source§impl ObjectAnims
impl ObjectAnims
Sourcepub fn bind(
&mut self,
node: &mut ObjectNode,
tween: Tween,
apply: Box<dyn FnMut(i32) -> Option<Rect>>,
delay_ticks: u32,
on_complete: Option<Box<dyn FnOnce()>>,
) -> ObjectAnimId
pub fn bind( &mut self, node: &mut ObjectNode, tween: Tween, apply: Box<dyn FnMut(i32) -> Option<Rect>>, delay_ticks: u32, on_complete: Option<Box<dyn FnOnce()>>, ) -> ObjectAnimId
Bind a tween animation to node.
The entry is stored in node’s animation slot (allocated lazily).
Returns an ObjectAnimId that can be passed to cancel,
pause_anim, or resume_anim.
delay_ticks: ticks before the tween begins stepping. During the delay
the entry is registered (the id is valid for cancel) but apply is not
called and no dirty rects are pushed (LPAR-06 §6.2).
on_complete: optional closure called exactly once when the tween
finishes naturally. Not called on cancel or on node detach/drop.
Sourcepub fn tick(&mut self, root: &mut ObjectNode, sink: &mut dyn FnMut(Rect))
pub fn tick(&mut self, root: &mut ObjectNode, sink: &mut dyn FnMut(Rect))
Advance all live animation entries by one tick, starting from root.
Walks the tree depth-first. For each node:
- Entries with
paused = trueare skipped. - Entries in their delay window (
delay_ticks > 0) decrement their delay counter and are otherwise skipped. - Once the delay expires, the tween is stepped and
applyis called with the new value. Any returnedRectis pushed tosink. - Entries whose tween reports
finishedafter stepping are removed and theiron_completehook is called (if any).
Hidden nodes are not skipped (LPAR-06 §6.5). Detached nodes are
unreachable from root and are therefore silently bypassed by
construction (LPAR-06 §6.4).
Sourcepub fn cancel(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
pub fn cancel(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
Remove the entry identified by id without firing its on_complete.
Walks the tree to locate the entry. Returns true if the id was
found and removed, false if not found (already completed or unknown).
Mirrors Animations::cancel semantics.
Sourcepub fn pause_anim(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
pub fn pause_anim(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
Pause the entry identified by id.
Returns true if found. A paused entry is not advanced by
tick.
Sourcepub fn resume_anim(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
pub fn resume_anim(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool
Resume the entry identified by id.
Returns true if found.