Skip to main content

InteractionTracker

Struct InteractionTracker 

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

A position and a scale driven by input, inertia and requests (Microsoft.UI.Composition.Interactions.InteractionTracker).

The main use is to bind visuals to it: an expression animation that references the tracker (set_reference_parameter("tracker", tracker)) reads tracker.Position, tracker.Scale and the other values of the tracker, e.g. -tracker.Position for the Offset of a scrolled visual.

Deviation (winui-composition.md): WinUI runs the tracker in the compositor. Here it runs on the UI thread, ticking with the animation frames of the media context while it is in inertia or in a custom animation, and publishes its values into its property set (properties) after every change; a reference to the tracker in an expression is a reference to that property set.

Implementations§

Source§

impl InteractionTracker

Source

pub fn create(compositor: &Rc<Compositor>) -> Rc<InteractionTracker>

InteractionTracker.Create(compositor).

Source

pub fn create_with_owner( compositor: &Rc<Compositor>, owner: Rc<dyn IInteractionTrackerOwner>, ) -> Rc<InteractionTracker>

InteractionTracker.CreateWithOwner(compositor, owner).

Source

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

The compositor of the tracker.

Source

pub fn properties(&self) -> &Rc<CompositionPropertySet>

The property set the tracker publishes its values into, under the WinUI names (Position, Scale, PositionVelocityInPixelsPerSecond, ScaleVelocityInPercentPerSecond, MinPosition, MaxPosition, MinScale, MaxScale, NaturalRestingPosition, NaturalRestingScale, PositionInertiaDecayRate, ScaleInertiaDecayRate, IsPositionRoundingSuggested, IsInertiaFromImpulse).

Deviation (winui-composition.md): in WinUI, Properties of a tracker is a property set of the application and the values are properties of the tracker itself; here the values live in this set, so entries the application adds must not use those names.

Source

pub fn owner(&self) -> Option<Rc<dyn IInteractionTrackerOwner>>

The owner given at creation.

Source

pub fn state(&self) -> InteractionTrackerState

The current state (not a WinUI member, see InteractionTrackerState).

Source

pub fn interaction_sources(&self) -> &CompositionInteractionSourceCollection

The sources whose input drives the tracker.

Source

pub fn position(&self) -> Vector3

The position (Position).

Source

pub fn position_velocity_in_pixels_per_second(&self) -> Vector3

The velocity of the position (PositionVelocityInPixelsPerSecond).

Source

pub fn scale(&self) -> f32

The scale (Scale).

Source

pub fn scale_velocity_in_percent_per_second(&self) -> f32

The velocity of the scale (ScaleVelocityInPercentPerSecond), in scale units per second.

Source

pub fn min_position(&self) -> Vector3

The lower boundary of the position (MinPosition).

Source

pub fn set_min_position(&self, value: Vector3)

Sets the lower boundary. The position is not moved by the change; the next request or inertia honours it.

Source

pub fn max_position(&self) -> Vector3

The upper boundary of the position (MaxPosition).

Source

pub fn set_max_position(&self, value: Vector3)

Source

pub fn min_scale(&self) -> f32

The lower boundary of the scale (MinScale).

Source

pub fn set_min_scale(&self, value: f32)

Source

pub fn max_scale(&self) -> f32

The upper boundary of the scale (MaxScale).

Source

pub fn set_max_scale(&self, value: f32)

Source

pub fn natural_resting_position(&self) -> Vector3

Where the natural decay of the velocity of the last inertia comes to rest, before the inertia modifiers and the boundaries (NaturalRestingPosition).

Source

pub fn natural_resting_scale(&self) -> f32

The natural resting scale of the last inertia (NaturalRestingScale).

Source

pub fn position_inertia_decay_rate(&self) -> Option<Vector3>

The decay rate of the position velocity per axis (PositionInertiaDecayRate); None for the default (DEFAULT_INERTIA_DECAY_RATE).

Source

pub fn set_position_inertia_decay_rate(&self, value: Option<Vector3>)

Source

pub fn scale_inertia_decay_rate(&self) -> Option<f32>

The decay rate of the scale velocity (ScaleInertiaDecayRate).

Source

pub fn set_scale_inertia_decay_rate(&self, value: Option<f32>)

Source

pub fn is_position_rounding_suggested(&self) -> bool

Whether the position should be rounded to whole pixels: true while the tracker is idle (IsPositionRoundingSuggested).

Source

pub fn is_inertia_from_impulse(&self) -> bool

Whether the current or last inertia comes from an impulse (IsInertiaFromImpulse).

Source

pub fn configure_position_x_inertia_modifiers( &self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>, )

ConfigurePositionXInertiaModifiers: the modifiers of the inertia of the X axis; an empty list removes them.

Source

pub fn configure_position_y_inertia_modifiers( &self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>, )

ConfigurePositionYInertiaModifiers.

Source

pub fn configure_scale_inertia_modifiers( &self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>, )

ConfigureScaleInertiaModifiers.

Source

pub fn try_update_position(&self, value: Vector3) -> i32

TryUpdatePosition(value): moves to value, clamped to the boundaries, and stops any inertia or custom animation. Ignored while interacting. Returns the id of the request.

Source

pub fn try_update_position_with_option( &self, value: Vector3, option: InteractionTrackerClampingOption, ) -> i32

TryUpdatePosition(value, option).

Source

pub fn try_update_position_by(&self, amount: Vector3) -> i32

TryUpdatePositionBy(amount): moves by amount, clamped.

Source

pub fn try_update_position_with_animation( &self, animation: impl Into<InteractionTrackerAnimation>, ) -> i32

TryUpdatePositionWithAnimation(animation): runs a custom animation of the position (a Vector3 key frame animation, or an expression). Ignored while interacting, or for an animation of another type.

Source

pub fn try_update_position_with_additional_velocity( &self, velocity_in_pixels_per_second: Vector3, ) -> i32

TryUpdatePositionWithAdditionalVelocity(velocity): adds velocity (pixels per second) to the current velocity and coasts in inertia. Ignored while interacting.

Source

pub fn try_update_scale(&self, value: f32, center_point: Vector3) -> i32

TryUpdateScale(value, centerPoint): scales to value, clamped to the scale boundaries, keeping center_point (in the coordinates of the viewport) in place. Ignored while interacting.

Source

pub fn try_update_scale_with_animation( &self, animation: impl Into<InteractionTrackerAnimation>, center_point: Vector3, ) -> i32

TryUpdateScaleWithAnimation(animation, centerPoint): runs a custom animation of the scale (a scalar key frame animation, or an expression). Ignored while interacting, or for an animation of another type.

Source

pub fn try_update_scale_with_additional_velocity( &self, velocity_in_percent_per_second: f32, center_point: Vector3, ) -> i32

TryUpdateScaleWithAdditionalVelocity(velocity, centerPoint): adds velocity (scale units per second) to the scale velocity and coasts in inertia around center_point. Ignored while interacting.

Trait Implementations§

Source§

impl AsCompositionObject for InteractionTracker

Source§

fn as_composition_object(&self) -> &CompositionObject

The composition object of the property set of the tracker: a reference to the tracker is a reference to its values.

Source§

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

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

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

The object as a property set, if it is one (the is CompositionPropertySet test of upstream).

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.