use std::ops::BitOr;
use crate::geo::ScreenCoordinate;
use crate::gestures::options::Axis;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PointerKind {
Mouse,
Touch,
Pen,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Modes {
pub rotate: bool,
pub box_zoom: bool,
pub zoom_out: bool,
}
impl BitOr for Modes {
type Output = Modes;
fn bitor(self, other: Modes) -> Modes {
Modes {
rotate: self.rotate || other.rotate,
box_zoom: self.box_zoom || other.box_zoom,
zoom_out: self.zoom_out || other.zoom_out,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Input {
PointerDown {
id: u32,
kind: PointerKind,
position: ScreenCoordinate,
modes: Modes,
},
PointerMove {
id: u32,
position: ScreenCoordinate,
},
PointerUp {
id: u32,
position: ScreenCoordinate,
},
PointerCancel {
id: u32,
},
Modes(Modes),
Delta {
position: ScreenCoordinate,
discrete: bool,
pan: ScreenCoordinate,
zoom: f64,
bearing: f64,
pitch: f64,
},
Pinch {
center: ScreenCoordinate,
scale: f64,
rotation: f64,
phase: PinchPhase,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PinchPhase {
Begin,
Update,
End,
Cancel,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GestureEvent {
Tap { id: u32, position: ScreenCoordinate },
LongPress { id: u32, position: ScreenCoordinate },
DoubleTap { id: u32, position: ScreenCoordinate },
TwoFingerTap { position: ScreenCoordinate },
Notch { axis: Axis, value: f64, kind: u32 },
}