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
impl InteractionTracker
Sourcepub fn create(compositor: &Rc<Compositor>) -> Rc<InteractionTracker>
pub fn create(compositor: &Rc<Compositor>) -> Rc<InteractionTracker>
InteractionTracker.Create(compositor).
Sourcepub fn create_with_owner(
compositor: &Rc<Compositor>,
owner: Rc<dyn IInteractionTrackerOwner>,
) -> Rc<InteractionTracker>
pub fn create_with_owner( compositor: &Rc<Compositor>, owner: Rc<dyn IInteractionTrackerOwner>, ) -> Rc<InteractionTracker>
InteractionTracker.CreateWithOwner(compositor, owner).
Sourcepub fn compositor(&self) -> &Rc<Compositor>
pub fn compositor(&self) -> &Rc<Compositor>
The compositor of the tracker.
Sourcepub fn properties(&self) -> &Rc<CompositionPropertySet>
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.
Sourcepub fn owner(&self) -> Option<Rc<dyn IInteractionTrackerOwner>>
pub fn owner(&self) -> Option<Rc<dyn IInteractionTrackerOwner>>
The owner given at creation.
Sourcepub fn state(&self) -> InteractionTrackerState
pub fn state(&self) -> InteractionTrackerState
The current state (not a WinUI member, see
InteractionTrackerState).
Sourcepub fn interaction_sources(&self) -> &CompositionInteractionSourceCollection
pub fn interaction_sources(&self) -> &CompositionInteractionSourceCollection
The sources whose input drives the tracker.
Sourcepub fn position_velocity_in_pixels_per_second(&self) -> Vector3
pub fn position_velocity_in_pixels_per_second(&self) -> Vector3
The velocity of the position (PositionVelocityInPixelsPerSecond).
Sourcepub fn scale_velocity_in_percent_per_second(&self) -> f32
pub fn scale_velocity_in_percent_per_second(&self) -> f32
The velocity of the scale (ScaleVelocityInPercentPerSecond), in
scale units per second.
Sourcepub fn min_position(&self) -> Vector3
pub fn min_position(&self) -> Vector3
The lower boundary of the position (MinPosition).
Sourcepub fn set_min_position(&self, value: Vector3)
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.
Sourcepub fn max_position(&self) -> Vector3
pub fn max_position(&self) -> Vector3
The upper boundary of the position (MaxPosition).
pub fn set_max_position(&self, value: Vector3)
pub fn set_min_scale(&self, value: f32)
pub fn set_max_scale(&self, value: f32)
Sourcepub fn natural_resting_position(&self) -> Vector3
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).
Sourcepub fn natural_resting_scale(&self) -> f32
pub fn natural_resting_scale(&self) -> f32
The natural resting scale of the last inertia (NaturalRestingScale).
Sourcepub fn position_inertia_decay_rate(&self) -> Option<Vector3>
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).
pub fn set_position_inertia_decay_rate(&self, value: Option<Vector3>)
Sourcepub fn scale_inertia_decay_rate(&self) -> Option<f32>
pub fn scale_inertia_decay_rate(&self) -> Option<f32>
The decay rate of the scale velocity (ScaleInertiaDecayRate).
pub fn set_scale_inertia_decay_rate(&self, value: Option<f32>)
Sourcepub fn is_position_rounding_suggested(&self) -> bool
pub fn is_position_rounding_suggested(&self) -> bool
Whether the position should be rounded to whole pixels: true while
the tracker is idle (IsPositionRoundingSuggested).
Sourcepub fn is_inertia_from_impulse(&self) -> bool
pub fn is_inertia_from_impulse(&self) -> bool
Whether the current or last inertia comes from an impulse
(IsInertiaFromImpulse).
Sourcepub fn configure_position_x_inertia_modifiers(
&self,
modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>,
)
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.
Sourcepub fn configure_position_y_inertia_modifiers(
&self,
modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>,
)
pub fn configure_position_y_inertia_modifiers( &self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>, )
ConfigurePositionYInertiaModifiers.
Sourcepub fn configure_scale_inertia_modifiers(
&self,
modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>,
)
pub fn configure_scale_inertia_modifiers( &self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>, )
ConfigureScaleInertiaModifiers.
Sourcepub fn try_update_position(&self, value: Vector3) -> i32
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.
Sourcepub fn try_update_position_with_option(
&self,
value: Vector3,
option: InteractionTrackerClampingOption,
) -> i32
pub fn try_update_position_with_option( &self, value: Vector3, option: InteractionTrackerClampingOption, ) -> i32
TryUpdatePosition(value, option).
Sourcepub fn try_update_position_by(&self, amount: Vector3) -> i32
pub fn try_update_position_by(&self, amount: Vector3) -> i32
TryUpdatePositionBy(amount): moves by amount, clamped.
Sourcepub fn try_update_position_with_animation(
&self,
animation: impl Into<InteractionTrackerAnimation>,
) -> i32
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.
Sourcepub fn try_update_position_with_additional_velocity(
&self,
velocity_in_pixels_per_second: Vector3,
) -> i32
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.
Sourcepub fn try_update_scale(&self, value: f32, center_point: Vector3) -> i32
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.
Sourcepub fn try_update_scale_with_animation(
&self,
animation: impl Into<InteractionTrackerAnimation>,
center_point: Vector3,
) -> i32
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.
Sourcepub fn try_update_scale_with_additional_velocity(
&self,
velocity_in_percent_per_second: f32,
center_point: Vector3,
) -> i32
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
impl AsCompositionObject for InteractionTracker
Source§fn as_composition_object(&self) -> &CompositionObject
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
fn composition_type_name(&self) -> &'static str
Source§fn as_property_set(self: Rc<Self>) -> Option<Rc<CompositionPropertySet>>
fn as_property_set(self: Rc<Self>) -> Option<Rc<CompositionPropertySet>>
is CompositionPropertySet test of upstream).Auto Trait Implementations§
impl !Freeze for InteractionTracker
impl !RefUnwindSafe for InteractionTracker
impl !Send for InteractionTracker
impl !Sync for InteractionTracker
impl !UnwindSafe for InteractionTracker
impl Unpin for InteractionTracker
impl UnsafeUnpin for InteractionTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more