Skip to main content

VisualInteractionSource

Struct VisualInteractionSource 

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

The input of the element of a visual, redirected to the interaction trackers the source is added to (Microsoft.UI.Composition.Interactions.VisualInteractionSource).

A drag starts with try_redirect_for_manipulation, called from a pointer pressed handler: the source captures the pointer to the element and follows its moves until it is released. Dragging content up increases Position.Y of the trackers, as scrolling does. The mouse wheel is redirected without a call when ManipulationRedirectionMode includes it.

Deviation (winui-composition.md): WinUI receives the input in the compositor once redirected. Here the source listens to the routed pointer events of the element (handled ones too) and drives the trackers on the UI thread; the element is the one of the visual (the element whose composition visual it is, or of its nearest ancestor) or the one given to create_for_element.

Implementations§

Source§

impl VisualInteractionSource

Source

pub fn create(source: &Rc<CompositionVisual>) -> Rc<VisualInteractionSource>

VisualInteractionSource.Create(source): a source for the input of the element of source.

Source

pub fn create_for_element( source: &Rc<CompositionVisual>, element: &Ref<InputElement>, ) -> Rc<VisualInteractionSource>

A source for the input of element, shown by source (not a WinUI member): for a visual that is not, or not yet, the composition visual of an element or below one.

Source

pub fn element(&self) -> Option<Ref<InputElement>>

The element whose input the source redirects, if it is known and alive. Looked up again from the visual while it is not known.

Source

pub fn source(&self) -> &Rc<CompositionVisual>

The visual the source was created for (Source).

Source

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

The compositor of the visual.

Source

pub fn position_x_source_mode(&self) -> InteractionSourceMode

PositionXSourceMode.

Source

pub fn set_position_x_source_mode(&self, value: InteractionSourceMode)

Source

pub fn position_y_source_mode(&self) -> InteractionSourceMode

PositionYSourceMode.

Source

pub fn set_position_y_source_mode(&self, value: InteractionSourceMode)

Source

pub fn scale_source_mode(&self) -> InteractionSourceMode

ScaleSourceMode. Only the Ctrl + mouse wheel scales: pinch input is not redirected.

Source

pub fn set_scale_source_mode(&self, value: InteractionSourceMode)

Source

pub fn position_x_chaining_mode(&self) -> InteractionChainingMode

PositionXChainingMode.

Deviation (winui-composition.md): stored only; a manipulation does not chain to the sources of ancestors.

Source

pub fn set_position_x_chaining_mode(&self, value: InteractionChainingMode)

Source

pub fn position_y_chaining_mode(&self) -> InteractionChainingMode

PositionYChainingMode (stored only).

Source

pub fn set_position_y_chaining_mode(&self, value: InteractionChainingMode)

Source

pub fn scale_chaining_mode(&self) -> InteractionChainingMode

ScaleChainingMode (stored only).

Source

pub fn set_scale_chaining_mode(&self, value: InteractionChainingMode)

Source

pub fn manipulation_redirection_mode( &self, ) -> VisualInteractionSourceRedirectionMode

ManipulationRedirectionMode: the input redirected without TryRedirectForManipulation. The mouse wheel is redirected when it includes PointerWheel; touchpads have no input of their own in FerroUI (their scrolling arrives as the wheel).

Source

pub fn set_manipulation_redirection_mode( &self, value: VisualInteractionSourceRedirectionMode, )

Source

pub fn is_position_x_rails_enabled(&self) -> bool

IsPositionXRailsEnabled: a drag that starts close to the X axis moves along it only.

Source

pub fn set_is_position_x_rails_enabled(&self, value: bool)

Source

pub fn is_position_y_rails_enabled(&self) -> bool

IsPositionYRailsEnabled.

Source

pub fn set_is_position_y_rails_enabled(&self, value: bool)

Source

pub fn pointer_wheel_config(&self) -> &Rc<InteractionSourceConfiguration>

PointerWheelConfig: the axes the redirected wheel drives.

Source

pub fn delta_position(&self) -> Vector3

The position change of the last move (DeltaPosition), as the trackers see it.

Deviation (winui-composition.md): the values of the input are properties of the UI-thread object; expressions cannot reference a source.

Source

pub fn delta_scale(&self) -> f32

The scale change of the last input (DeltaScale), as a factor.

Source

pub fn position(&self) -> Vector3

The position of the current drag since it started (Position).

Source

pub fn position_velocity(&self) -> Vector3

The velocity of the current drag (PositionVelocity).

Source

pub fn scale(&self) -> f32

The scale of the input (Scale).

Source

pub fn scale_velocity(&self) -> f32

The velocity of the scale of the input (ScaleVelocity).

Source

pub fn try_redirect_for_manipulation(&self, e: &PointerPressedEventArgs) -> bool

TryRedirectForManipulation(pointerPoint), from the pressed event: the drag of the pressed pointer drives the trackers until it is released. Returns whether the drag was redirected (not a WinUI result): not when a drag of this source is in progress, when no axis is enabled, or when the source has no element.

Deviation (winui-composition.md): any pointer type is redirected, mouse included.

Source

pub fn try_redirect_for_manipulation_point( &self, point: &PointerPoint, element: &Ref<InputElement>, ) -> bool

TryRedirectForManipulation(pointerPoint) with the element that captures the pointer. The position of point must be in the coordinates of the top level (get_current_point(None)), as the moves are followed there.

Trait Implementations§

Source§

impl Drop for VisualInteractionSource

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.