Turn Touch into a touch::Event enum
This commit is contained in:
parent
09110a93b0
commit
3bdf931925
9 changed files with 89 additions and 118 deletions
|
|
@ -3,33 +3,21 @@ use crate::Point;
|
|||
|
||||
/// A touch interaction.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Touch {
|
||||
/// The finger of the touch.
|
||||
pub finger: Finger,
|
||||
#[allow(missing_docs)]
|
||||
pub enum Event {
|
||||
/// A touch interaction was started.
|
||||
FingerPressed { id: Finger, position: Point },
|
||||
|
||||
/// The position of the touch.
|
||||
pub position: Point,
|
||||
/// An on-going touch interaction was moved.
|
||||
FingerMoved { id: Finger, position: Point },
|
||||
|
||||
/// The state of the touch.
|
||||
pub phase: Phase,
|
||||
/// A touch interaction was ended.
|
||||
FingerLifted { id: Finger, position: Point },
|
||||
|
||||
/// A touch interaction was canceled.
|
||||
FingerLost { id: Finger, position: Point },
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue