Add UIGestureRecognizerDelegate and PanGestureRecogniser (#3597)
- Allow all gestures simultaneously recognized. - Add PanGestureRecogniser with min/max number of touches. - Fix sending delta values relative to Update instead to match macOS. - Fix rotation gesture units from iOS to be in degrees instead of radians. Co-authored-by: Mads Marquart <mads@marquart.dk>
This commit is contained in:
parent
94664ff687
commit
fd477986de
8 changed files with 289 additions and 31 deletions
26
src/event.rs
26
src/event.rs
|
|
@ -293,6 +293,19 @@ pub enum WindowEvent {
|
|||
phase: TouchPhase,
|
||||
},
|
||||
|
||||
/// N-finger pan gesture
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - Only available on **iOS**.
|
||||
/// - On iOS, not recognized by default. It must be enabled when needed.
|
||||
PanGesture {
|
||||
device_id: DeviceId,
|
||||
/// Change in pixels of pan gesture from last update.
|
||||
delta: PhysicalPosition<f32>,
|
||||
phase: TouchPhase,
|
||||
},
|
||||
|
||||
/// Double tap gesture.
|
||||
///
|
||||
/// On a Mac, smart magnification is triggered by a double tap with two fingers
|
||||
|
|
@ -322,7 +335,12 @@ pub enum WindowEvent {
|
|||
///
|
||||
/// - Only available on **macOS** and **iOS**.
|
||||
/// - On iOS, not recognized by default. It must be enabled when needed.
|
||||
RotationGesture { device_id: DeviceId, delta: f32, phase: TouchPhase },
|
||||
RotationGesture {
|
||||
device_id: DeviceId,
|
||||
/// change in rotation in degrees
|
||||
delta: f32,
|
||||
phase: TouchPhase,
|
||||
},
|
||||
|
||||
/// Touchpad pressure event.
|
||||
///
|
||||
|
|
@ -993,6 +1011,7 @@ impl PartialEq for InnerSizeWriter {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::dpi::PhysicalPosition;
|
||||
use crate::event;
|
||||
use std::collections::{BTreeSet, HashSet};
|
||||
|
||||
|
|
@ -1055,6 +1074,11 @@ mod tests {
|
|||
delta: 0.0,
|
||||
phase: event::TouchPhase::Started,
|
||||
});
|
||||
with_window_event(PanGesture {
|
||||
device_id: did,
|
||||
delta: PhysicalPosition::<f32>::new(0.0, 0.0),
|
||||
phase: event::TouchPhase::Started,
|
||||
});
|
||||
with_window_event(TouchpadPressure { device_id: did, pressure: 0.0, stage: 0 });
|
||||
with_window_event(AxisMotion { device_id: did, axis: 0, value: 0.0 });
|
||||
with_window_event(Touch(event::Touch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue