Skip to main content

ObjectAnims

Struct ObjectAnims 

Source
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

Source

pub fn new() -> Self

Create a new ObjectAnims id allocator.

Source

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.

Source

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 = true are 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 apply is called with the new value. Any returned Rect is pushed to sink.
  • Entries whose tween reports finished after stepping are removed and their on_complete hook 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).

Source

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.

Source

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.

Source

pub fn resume_anim(&mut self, root: &mut ObjectNode, id: ObjectAnimId) -> bool

Resume the entry identified by id.

Returns true if found.

Trait Implementations§

Source§

impl Default for ObjectAnims

Source§

fn default() -> ObjectAnims

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.