From d3572e1b819ff4d40de4f39f48eab71b9d0d4d5e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 19 Mar 2020 12:17:16 +0100 Subject: Turn `Touch` into a struct and add finger id --- native/src/input/touch.rs | 69 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 36 deletions(-) (limited to 'native/src/input/touch.rs') diff --git a/native/src/input/touch.rs b/native/src/input/touch.rs index 7c4a6210..ea879427 100644 --- a/native/src/input/touch.rs +++ b/native/src/input/touch.rs @@ -1,39 +1,36 @@ //! Build touch events. -/// The touch of a mobile device. + +use crate::Point; + +/// A touch interaction. #[derive(Debug, Clone, Copy, PartialEq)] -pub enum Touch { - /// The touch cursor was started - Started { - /// The X coordinate of the touch position - x: f32, - - /// The Y coordinate of the touch position - y: f32, - }, - /// The touch cursor was ended - Ended { - /// The X coordinate of the touch position - x: f32, - - /// The Y coordinate of the touch position - y: f32, - }, - - /// The touch was moved. - Moved { - /// The X coordinate of the touch position - x: f32, - - /// The Y coordinate of the touch position - y: f32, - }, - - /// Some canceled button. - Cancelled { - /// The X coordinate of the touch position - x: f32, - - /// The Y coordinate of the touch position - y: f32, - }, +pub struct Touch { + /// The finger of the touch. + pub finger: Finger, + + /// The position of the touch. + pub position: Point, + + /// The state of the touch. + pub phase: Phase, +} + +/// A unique identifier representing a finger on a touch interaction. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct Finger(pub u64); + +/// The state of a touch interaction. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Phase { + /// A touch interaction was started. + Started, + + /// An on-going touch interaction was moved. + Moved, + + /// A touch interaction was ended. + Ended, + + /// A touch interaction was canceled. + Canceled, } -- cgit