Skip to main content

TouchState

Struct TouchState 

Source
pub struct TouchState {
    pub pinch_delta: Option<f64>,
    pub rotation_delta: Option<f64>,
    pub pan_delta: Option<(f64, f64)>,
    /* private fields */
}
Expand description

Multi-touch state tracker

Fields§

§pinch_delta: Option<f64>

Pinch gesture: distance delta between two touches

§rotation_delta: Option<f64>

Rotation gesture: angle delta between two touches (radians)

§pan_delta: Option<(f64, f64)>

Two-finger pan: average movement of two touches

Implementations§

Source§

impl TouchState

Source

pub fn new() -> Self

Create new empty touch state

Source

pub fn update_touch( &mut self, id: TouchId, x: f64, y: f64, time: f64, force: Option<f64>, )

Add or update a touch point

Source

pub fn touch_start( &mut self, id: TouchId, x: f64, y: f64, time: f64, force: Option<f64>, )

Start a new touch point (convenience wrapper)

Source

pub fn touch_move( &mut self, id: TouchId, x: f64, y: f64, time: f64, force: Option<f64>, )

Move an existing touch point (convenience wrapper)

Source

pub fn touch_end(&mut self, id: TouchId)

End a touch point (convenience wrapper)

Source

pub fn touch_cancel(&mut self, id: TouchId)

Cancel a touch point (convenience wrapper for touch_end)

Source

pub fn remove_touch(&mut self, id: TouchId)

Remove a touch point

Source

pub fn clear(&mut self)

Clear all touches

Source

pub fn clear_deltas(&mut self)

Clear frame-specific gesture deltas

Source

pub fn primary_touch(&self) -> Option<&Touch>

Get the primary touch (first touch that went down)

Source

pub fn get_touch(&self, id: TouchId) -> Option<&Touch>

Get touch by ID

Source

pub fn touches(&self) -> impl Iterator<Item = &Touch>

Get all active touches

Source

pub fn touch_count(&self) -> usize

Get number of active touches

Source

pub fn has_touches(&self) -> bool

Check if any touches are active

Source

pub fn centroid(&self) -> Option<(f64, f64)>

Get centroid (average position) of all touches

Source

pub fn is_two_finger_gesture(&self) -> bool

Check if this is a two-finger gesture

Source

pub fn is_pinching(&self) -> bool

Check if currently pinching

Source

pub fn is_rotating(&self) -> bool

Check if currently rotating

Source

pub fn is_two_finger_panning(&self) -> bool

Check if currently panning with two fingers

Trait Implementations§

Source§

impl Clone for TouchState

Source§

fn clone(&self) -> TouchState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TouchState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TouchState

Source§

fn default() -> TouchState

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.