Skip to main content

AnimationController

Struct AnimationController 

Source
pub struct AnimationController { /* private fields */ }
Expand description

Controls running animations: pauses and resumes them, moves them to a point (Progress) and changes their speed (PlaybackRate) (WinUI AnimationController).

An animation comes under a controller when it is started with start_animation_with_controller, or through try_get_animation_controller of the object it animates. Key frame and natural motion animations can be controlled; expression animations are not affected. One controller can control several animations.

Progress and PlaybackRate can be animated (controller.start_animation("Progress", expression)), and the controller can be a reference parameter of an expression (controller.Progress).

Implementations§

Source§

impl AnimationController

Source

pub const MAX_PLAYBACK_RATE: f32 = 1000.0

The highest playback rate (WinUI MaxPlaybackRate).

Source

pub const MIN_PLAYBACK_RATE: f32 = -1000.0

The lowest playback rate (WinUI MinPlaybackRate); a negative rate plays backwards.

Source

pub fn compositor(&self) -> &Rc<Compositor>

The compositor of the controller.

Source

pub fn pause(&self)

Pauses the controlled animations: their time stops, and they do not end while paused.

Source

pub fn resume(&self)

Resumes the controlled animations from where they were paused.

Source

pub fn is_paused(&self) -> bool

Whether the controller is paused (not a WinUI member).

Source

pub fn playback_rate(&self) -> f32

The speed of the controlled animations: 1 is normal speed, 2 twice as fast, a negative rate plays backwards.

Source

pub fn set_playback_rate(&self, value: f32)

Sets the playback rate, clamped to MIN_PLAYBACK_RATE..MAX_PLAYBACK_RATE.

Source

pub fn progress(&self) -> f32

The progress last assigned (0..1).

Source

pub fn set_progress(&self, value: f32)

Moves the controlled animations to a point between their start (0) and their end (1), clamped to that range. A playing animation goes on from there; a paused one stays there.

Source

pub fn progress_behavior(&self) -> AnimationControllerProgressBehavior

What the progress covers.

Source

pub fn set_progress_behavior(&self, value: AnimationControllerProgressBehavior)

Trait Implementations§

Source§

impl AsCompositionObject for AnimationController

Source§

fn as_property_set(self: Rc<Self>) -> Option<Rc<CompositionPropertySet>>

An expression refers to the controller through its property set (controller.Progress).

Source§

fn as_composition_object(&self) -> &CompositionObject

The embedded CompositionObject.
Source§

fn composition_type_name(&self) -> &'static str

The name of the class of the object, for messages.
Source§

impl ICompositionObjectAnimations for AnimationController

Source§

fn try_start_animation( &self, property_name: &str, animation: &dyn ICompositionAnimation, final_value: Option<ExpressionVariant>, ) -> bool

Progress and PlaybackRate can be animated.

Source§

fn get_composition_property( &self, property_name: &str, ) -> Option<&'static CompositionProperty>

The composition property with the given name.
Source§

fn composition_object(&self) -> &CompositionObject

The embedded CompositionObject.
Source§

fn start_animation( &self, property_name: &str, animation: &dyn ICompositionAnimation, )

Connects an animation with the named property of the object and starts the animation.
Source§

fn start_animation_with_final_value( &self, property_name: &str, animation: &dyn ICompositionAnimation, final_value: Option<ExpressionVariant>, )

See start_animation. property_name may name a sub-channel of a vector property (Offset.X, Scale.XY, components X, Y, Z, W in any case): the animation then animates a value of the sub-channel’s type (a scalar for one component, a Vector2 for two, …) and leaves the other components alone. Several sub-channels of one property run together; an animation of the whole property replaces them.
Source§

fn start_animation_with_controller( &self, property_name: &str, animation: &dyn ICompositionAnimation, controller: &Rc<AnimationController>, )

StartAnimation(propertyName, animation, animationController): starts the animation under controller, which can pause, resume, scrub and speed it up. property_name may name a sub-channel, as for start_animation.
Source§

fn try_get_animation_controller( &self, property_name: &str, ) -> Option<Rc<AnimationController>>

The controller of the animation of the named property (TryGetAnimationController): the controller it was started with, or a new controller that takes the running animation over. None when no animation was started on the property through this object, or it was stopped.
Source§

fn stop_animation(&self, property_name: &str)

Disconnects an animation from the named property and stops it, applying its stop behavior. property_name may name a sub-channel (Offset.X): the animations of the sub-channels that share a component with it are stopped.
Source§

fn start_animation_group(&self, grp: &dyn ICompositionAnimationBase)

Starts an animation group. The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup. All the animations in the group will be started at the same time on the object.
Source§

fn start_animation_group_part( &self, animation: &dyn ICompositionAnimation, target: &str, final_value: ExpressionVariant, ) -> bool

StartAnimationGroupPart.
Source§

fn start_animation_group_for( &self, grp: &dyn ICompositionAnimationBase, target: &str, final_value: ExpressionVariant, ) -> bool

Starts an animation or an animation group triggered by the change of property target to final_value. Returns whether one of the animations targets that property.
Source§

fn stop_animation_group(&self, grp: &dyn ICompositionAnimationBase)

Stops an animation group.

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> 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<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
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, 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.