InteractionTracker
struct · ferroui-base · v0.5.0
struct InteractionTracker
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.
Members
createcreate_with_ownercompositorpropertiesownerstateinteraction_sourcespositionposition_velocity_in_pixels_per_secondscalescale_velocity_in_percent_per_secondmin_positionset_min_positionmax_positionset_max_positionmin_scaleset_min_scalemax_scaleset_max_scalenatural_resting_positionnatural_resting_scaleposition_inertia_decay_rateset_position_inertia_decay_ratescale_inertia_decay_rateset_scale_inertia_decay_rateis_position_rounding_suggestedis_inertia_from_impulseconfigure_position_x_inertia_modifiersconfigure_position_y_inertia_modifiersconfigure_scale_inertia_modifierstry_update_positiontry_update_position_with_optiontry_update_position_bytry_update_position_with_animationtry_update_position_with_additional_velocitytry_update_scaletry_update_scale_with_animationtry_update_scale_with_additional_velocity
create
fn create(compositor: &Rc<Compositor>) -> Rc<InteractionTracker>
InteractionTracker.Create(compositor).
create_with_owner
fn create_with_owner(compositor: &Rc<Compositor>, owner: Rc<dyn IInteractionTrackerOwner>) -> Rc<InteractionTracker>
InteractionTracker.CreateWithOwner(compositor, owner).
compositor
fn compositor(self: &Self) -> &Rc<Compositor>
The compositor of the tracker.
properties
fn properties(self: &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.
owner
fn owner(self: &Self) -> Option<Rc<dyn IInteractionTrackerOwner>>
The owner given at creation.
state
fn state(self: &Self) -> InteractionTrackerState
The current state (not a WinUI member, see
InteractionTrackerState).
interaction_sources
fn interaction_sources(self: &Self) -> &CompositionInteractionSourceCollection
The sources whose input drives the tracker.
position
fn position(self: &Self) -> Vector3
The position (Position).
position_velocity_in_pixels_per_second
fn position_velocity_in_pixels_per_second(self: &Self) -> Vector3
The velocity of the position (PositionVelocityInPixelsPerSecond).
scale
fn scale(self: &Self) -> f32
The scale (Scale).
scale_velocity_in_percent_per_second
fn scale_velocity_in_percent_per_second(self: &Self) -> f32
The velocity of the scale (ScaleVelocityInPercentPerSecond), in
scale units per second.
min_position
fn min_position(self: &Self) -> Vector3
The lower boundary of the position (MinPosition).
set_min_position
fn set_min_position(self: &Self, value: Vector3)
Sets the lower boundary. The position is not moved by the change; the next request or inertia honours it.
max_position
fn max_position(self: &Self) -> Vector3
The upper boundary of the position (MaxPosition).
set_max_position
fn set_max_position(self: &Self, value: Vector3)
min_scale
fn min_scale(self: &Self) -> f32
The lower boundary of the scale (MinScale).
set_min_scale
fn set_min_scale(self: &Self, value: f32)
max_scale
fn max_scale(self: &Self) -> f32
The upper boundary of the scale (MaxScale).
set_max_scale
fn set_max_scale(self: &Self, value: f32)
natural_resting_position
fn natural_resting_position(self: &Self) -> Vector3
Where the natural decay of the velocity of the last inertia comes to
rest, before the inertia modifiers and the boundaries
(NaturalRestingPosition).
natural_resting_scale
fn natural_resting_scale(self: &Self) -> f32
The natural resting scale of the last inertia (NaturalRestingScale).
position_inertia_decay_rate
fn position_inertia_decay_rate(self: &Self) -> Option<Vector3>
The decay rate of the position velocity per axis
(PositionInertiaDecayRate); None for the default
(DEFAULT_INERTIA_DECAY_RATE).
set_position_inertia_decay_rate
fn set_position_inertia_decay_rate(self: &Self, value: Option<Vector3>)
scale_inertia_decay_rate
fn scale_inertia_decay_rate(self: &Self) -> Option<f32>
The decay rate of the scale velocity (ScaleInertiaDecayRate).
set_scale_inertia_decay_rate
fn set_scale_inertia_decay_rate(self: &Self, value: Option<f32>)
is_position_rounding_suggested
fn is_position_rounding_suggested(self: &Self) -> bool
Whether the position should be rounded to whole pixels: true while
the tracker is idle (IsPositionRoundingSuggested).
is_inertia_from_impulse
fn is_inertia_from_impulse(self: &Self) -> bool
Whether the current or last inertia comes from an impulse
(IsInertiaFromImpulse).
configure_position_x_inertia_modifiers
fn configure_position_x_inertia_modifiers(self: &Self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>)
ConfigurePositionXInertiaModifiers: the modifiers of the inertia of
the X axis; an empty list removes them.
configure_position_y_inertia_modifiers
fn configure_position_y_inertia_modifiers(self: &Self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>)
ConfigurePositionYInertiaModifiers.
configure_scale_inertia_modifiers
fn configure_scale_inertia_modifiers(self: &Self, modifiers: impl IntoIterator<Item = InteractionTrackerInertiaModifier>)
ConfigureScaleInertiaModifiers.
try_update_position
fn try_update_position(self: &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.
try_update_position_with_option
fn try_update_position_with_option(self: &Self, value: Vector3, option: InteractionTrackerClampingOption) -> i32
TryUpdatePosition(value, option).
try_update_position_by
fn try_update_position_by(self: &Self, amount: Vector3) -> i32
TryUpdatePositionBy(amount): moves by amount, clamped.
try_update_position_with_animation
fn try_update_position_with_animation(self: &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.
try_update_position_with_additional_velocity
fn try_update_position_with_additional_velocity(self: &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.
try_update_scale
fn try_update_scale(self: &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.
try_update_scale_with_animation
fn try_update_scale_with_animation(self: &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.
try_update_scale_with_additional_velocity
fn try_update_scale_with_additional_velocity(self: &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
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherAsCompositionObject
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.