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 enum DragAction {
#[default]
Pan,
None,
Rotate,
BoxZoom,
Defer,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct PointerFlags {
pub allow_pinch: bool,
pub allow_tap_drag: bool,
pub zoom_out: bool,
}
impl PointerFlags {
#[must_use]
pub const fn for_kind(kind: PointerKind) -> Self {
match kind {
PointerKind::Touch => Self { allow_pinch: true, allow_tap_drag: true, zoom_out: false },
PointerKind::Mouse | PointerKind::Pen => {
Self { allow_pinch: false, allow_tap_drag: false, zoom_out: false }
}
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Modes {
pub rotate: bool,
pub box_zoom: bool,
pub zoom_out: bool,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Input {
PointerDown {
id: u32,
kind: PointerKind,
position: ScreenCoordinate,
drag_action: DragAction,
flags: PointerFlags,
},
PointerMove {
id: u32,
position: ScreenCoordinate,
},
PointerUp {
id: u32,
position: ScreenCoordinate,
},
PointerCancel {
id: u32,
},
Modes(Modes),
Delta {
anchor: Option<ScreenCoordinate>,
discrete: bool,
pan: ScreenCoordinate,
zoom: f64,
bearing: f64,
pitch: f64,
},
DeltaEnd {
fling: Option<Fling>,
},
DeltaCancel,
DragDecision {
id: u32,
drag_action: DragAction,
},
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Fling {
pub anchor: Option<ScreenCoordinate>,
pub pan: ScreenCoordinate,
pub zoom: f64,
pub bearing: f64,
pub pitch: f64,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GestureEvent {
Tap { id: u32, position: ScreenCoordinate },
SingleTap { id: u32, position: ScreenCoordinate },
LongPress { id: u32, position: ScreenCoordinate },
DoubleTap { id: u32, position: ScreenCoordinate },
TwoFingerTap { position: ScreenCoordinate },
Notch { axis: Axis, value: f64, kind: u32 },
DragPending { id: u32, origin: ScreenCoordinate, position: ScreenCoordinate },
}