Skip to main content

Animation

Trait Animation 

Source
pub trait Animation<T>: Sized + 'static
where T: 'static,
{
Show 13 methods // Required methods fn add_listener(self: Handle<Self>, app: &mut App, listener: Listener); fn remove_listener(self: Handle<Self>, app: &mut App, listener: &Listener); fn add_status_listener( self: Handle<Self>, app: &mut App, listener: AnimationStatusListener, ); fn remove_status_listener( self: Handle<Self>, app: &mut App, listener: &AnimationStatusListener, ); fn status(self: Handle<Self>, app: &App) -> AnimationStatus; fn value(self: Handle<Self>, app: &App) -> T; // Provided methods fn is_dismissed(self: Handle<Self>, app: &App) -> bool { ... } fn is_completed(self: Handle<Self>, app: &App) -> bool { ... } fn is_animating(self: Handle<Self>, app: &App) -> bool { ... } fn is_forward_or_completed(self: Handle<Self>, app: &App) -> bool { ... } fn to_string_details(self: Handle<Self>, app: &App) -> String { ... } fn to_string(self: Handle<Self>, app: &App) -> String { ... } fn as_animation(self: Handle<Self>) -> AnyAnimation<T> { ... }
}
Expand description

A value which might change over time, moving forward or backward.

This is what a concrete animation implements — Dart’s class X extends Animation<T>. A field or parameter Dart types as Animation<T> holds the erased AnimationRef<T> instead; get one from a Ref with Retained::erase, and the bare AnyAnimation<T> that names it without keeping it from as_animation.

The members take self: Handle<Self> rather than &self, for the reason recorded on the listener_helpers traits: a &self receiver would borrow this animation’s slot for the whole call, and the listener members hand &mut App onward to reach other objects and run listeners.

Required Methods§

Source

fn add_listener(self: Handle<Self>, app: &mut App, listener: Listener)

Calls the listener every time the value of the animation changes.

Listeners can be removed with remove_listener.

Source

fn remove_listener(self: Handle<Self>, app: &mut App, listener: &Listener)

Stop calling the listener every time the value of the animation changes.

Listeners can be added with add_listener.

Source

fn add_status_listener( self: Handle<Self>, app: &mut App, listener: AnimationStatusListener, )

Calls listener every time the status of the animation changes.

Listeners can be removed with remove_status_listener.

Source

fn remove_status_listener( self: Handle<Self>, app: &mut App, listener: &AnimationStatusListener, )

Stops calling the listener every time the status of the animation changes.

Listeners can be added with add_status_listener.

Source

fn status(self: Handle<Self>, app: &App) -> AnimationStatus

The current status of this animation.

Source

fn value(self: Handle<Self>, app: &App) -> T

The current value of the animation.

Returns an owned T, not a reference: an animation may compute its value from its parent’s (Dart’s CurvedAnimation.value does), so there is no stored field for a reference to point at.

Provided Methods§

Source

fn is_dismissed(self: Handle<Self>, app: &App) -> bool

Whether this animation is stopped at the beginning.

Source

fn is_completed(self: Handle<Self>, app: &App) -> bool

Whether this animation is stopped at the end.

Source

fn is_animating(self: Handle<Self>, app: &App) -> bool

Whether this animation is running in either direction.

Source

fn is_forward_or_completed(self: Handle<Self>, app: &App) -> bool

Whether the current aim of this animation is toward completion.

Source

fn to_string_details(self: Handle<Self>, app: &App) -> String

Dart’s Animation.toStringDetails: the status as its arrow.

Source

fn to_string(self: Handle<Self>, app: &App) -> String

Dart’s Animation.toString: the identity and toStringDetails.

Source

fn as_animation(self: Handle<Self>) -> AnyAnimation<T>

This animation as the erased AnyAnimation<T> — what to pass where a Dart API takes an Animation<T>.

The object is untouched; this mints an erased second handle to it, so concrete members stay reachable through the typed one while the erased handle sits in a field Dart types as Animation<T>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§