summaryrefslogtreecommitdiffstats
path: root/native/src/input/touch.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-19 12:17:16 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-19 12:17:16 +0100
commitd3572e1b819ff4d40de4f39f48eab71b9d0d4d5e (patch)
tree80d635749e4941004055f16a7ca5c35e11f3caa9 /native/src/input/touch.rs
parente19a07d40049f40f36d879a498fab4ce63778b27 (diff)
downloadiced-d3572e1b819ff4d40de4f39f48eab71b9d0d4d5e.tar.gz
iced-d3572e1b819ff4d40de4f39f48eab71b9d0d4d5e.tar.bz2
iced-d3572e1b819ff4d40de4f39f48eab71b9d0d4d5e.zip
Turn `Touch` into a struct and add finger id
Diffstat (limited to 'native/src/input/touch.rs')
-rw-r--r--native/src/input/touch.rs69
1 files changed, 33 insertions, 36 deletions
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,
}