Skip to main content

TrainHoppingAnimation

Struct TrainHoppingAnimation 

Source
pub struct TrainHoppingAnimation {
    pub on_switched_train: Option<Listener>,
    /* private fields */
}
Expand description

This animation starts by proxying one animation, but when the value of that animation crosses the value of the second (either because the second is going in the opposite direction, or because the one overtakes the other), the animation hops over to proxying the second animation.

When the TrainHoppingAnimation starts proxying the second animation instead of the first, the on_switched_train callback is called.

If the two animations start at the same value, then the TrainHoppingAnimation immediately hops to the second animation, and the on_switched_train callback is not called. If only one animation is provided (i.e. if the second is None), then the TrainHoppingAnimation just proxies the first animation.

Since this object must track the two animations even when it has no listeners of its own, instead of shutting down when all its listeners are removed, it exposes a dispose method. Call this method to shut this object down.

Fields§

§on_switched_train: Option<Listener>

Called when this animation switches to be driven by the second animation.

This is not called if the two animations provided to the constructor have the same value at the time of the call to the constructor. In that case, the second animation is used from the start, and the first is ignored.

Implementations§

Source§

impl TrainHoppingAnimation

Source

pub fn new( app: &mut App, current_train: Retained<AnyAnimation<f64>>, next_train: Option<Retained<AnyAnimation<f64>>>, on_switched_train: Option<Listener>, ) -> Retained<Handle<TrainHoppingAnimation>>

Creates a train-hopping animation.

If the next train is None, then this object will just proxy the first animation and never hop. Dart’s constructor registers tear-offs of the object under construction, so creation goes through the App.

Source

pub fn current_train(&self) -> Option<AnyAnimation<f64>>

The animation that is currently driving this animation.

The identity of this object will change from the first animation to the second animation when on_switched_train is called.

Source

pub fn dispose(self: Handle<TrainHoppingAnimation>, app: &mut App)

Frees all the resources used by this performance. After this is called, this object is no longer usable.

Trait Implementations§

Source§

impl Animation<f64> for TrainHoppingAnimation

Source§

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

Calls the listener every time the value of the animation changes. Read more
Source§

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

Stop calling the listener every time the value of the animation changes. Read more
Source§

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

Calls listener every time the status of the animation changes. Read more
Source§

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

Stops calling the listener every time the status of the animation changes. Read more
Source§

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

The current status of this animation.
Source§

fn value(self: Handle<TrainHoppingAnimation>, app: &App) -> f64

The current value of the animation. Read more
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>. Read more
Source§

impl AnimationEagerListenerMixin for TrainHoppingAnimation

Source§

fn did_register_listener(self: Handle<Self>, _app: &mut App)

This implementation ignores listener registrations.
Source§

fn did_unregister_listener(self: Handle<Self>, _app: &mut App)

This implementation ignores listener registrations.
Source§

fn dispose(self: Handle<Self>, _app: &mut App)

Release the resources used by this object. The object is no longer usable after this method is called. Read more
Source§

impl AnimationLocalListenersMixin for TrainHoppingAnimation

Source§

fn local_listeners_data( self: Handle<TrainHoppingAnimation>, app: &App, ) -> &AnimationLocalListenersData

The mixin’s field on the host.
Source§

fn local_listeners_data_mut( self: Handle<TrainHoppingAnimation>, app: &mut App, ) -> &mut AnimationLocalListenersData

The mixin’s field on the host, mutably.
Source§

fn did_register_listener(self: Handle<TrainHoppingAnimation>, app: &mut App)

Called immediately before a listener is added via add_listener. Read more
Source§

fn did_unregister_listener(self: Handle<TrainHoppingAnimation>, app: &mut App)

Called immediately after a listener is removed via remove_listener. Read more
Source§

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

Calls the listener every time the value of the animation changes. Read more
Source§

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

Stop calling the listener every time the value of the animation changes. Read more
Source§

fn clear_listeners(self: Handle<Self>, app: &mut App)

Removes all listeners added with add_listener. Read more
Source§

fn notify_listeners(self: Handle<Self>, app: &mut App)

Calls all the listeners. Read more
Source§

impl AnimationLocalStatusListenersMixin for TrainHoppingAnimation

Source§

fn local_status_listeners_data( self: Handle<TrainHoppingAnimation>, app: &App, ) -> &AnimationLocalStatusListenersData

The mixin’s field on the host.
Source§

fn local_status_listeners_data_mut( self: Handle<TrainHoppingAnimation>, app: &mut App, ) -> &mut AnimationLocalStatusListenersData

The mixin’s field on the host, mutably.
Source§

fn did_register_listener(self: Handle<TrainHoppingAnimation>, app: &mut App)

Called immediately before a status listener is added via add_status_listener. Read more
Source§

fn did_unregister_listener(self: Handle<TrainHoppingAnimation>, app: &mut App)

Called immediately after a status listener is removed via remove_status_listener. Read more
Source§

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

Calls listener every time the status of the animation changes. Read more
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. Read more
Source§

fn clear_status_listeners(self: Handle<Self>, app: &mut App)

Removes all listeners added with add_status_listener. Read more
Source§

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

Calls all the status listeners. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for TrainHoppingAnimation

§

impl !Send for TrainHoppingAnimation

§

impl !Sync for TrainHoppingAnimation

§

impl !UnwindSafe for TrainHoppingAnimation

§

impl Forget for TrainHoppingAnimation

§

impl Freeze for TrainHoppingAnimation
where NonZero<u32>: Freeze, &'static AnimationVTable<f64>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, *const (): Freeze, *const u8 is !null: Freeze, PhantomData<usize>: Freeze, PhantomData<Bucket<Listener, usize>>: Freeze, PhantomData<AnimationStatusListener>: Freeze, PhantomData<(AnimationStatusListener, ())>: Freeze,

§

impl Move for TrainHoppingAnimation

§

impl Unpin for TrainHoppingAnimation
where NonZero<u32>: Unpin, &'static AnimationVTable<f64>: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, *const (): Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(AnimationStatus, &mut App)>: Unpin,

§

impl UnsafeUnpin for TrainHoppingAnimation
where NonZeroU32Inner: UnsafeUnpin, &'static AnimationVTable<f64>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, *const (): UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<usize>: UnsafeUnpin, PhantomData<Bucket<Listener, usize>>: UnsafeUnpin, PhantomData<AnimationStatusListener>: UnsafeUnpin, PhantomData<(AnimationStatusListener, ())>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, !>

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

Source§

fn upcast(&self) -> Option<&T>