pub struct GestureProfile {
pub tap_max_distance: f32,
pub tap_max_seconds: f64,
pub drag_min_distance: f32,
pub drag_min_seconds: f64,
pub swipe_min_distance: f32,
pub swipe_max_seconds: f64,
}Expand description
Logical-pixel distances and supplied-time seconds for opt-in recognition.
Distances must be finite, with 0 <= tap_max_distance < drag_min_distance <= swipe_min_distance <= 1e6. Times must be finite in 0..=3600 seconds.
Every threshold is inclusive. Tap uses maximum excursion from the starting
point and maximum duration; drag latches once maximum excursion and minimum
duration both qualify. Swipe uses final net displacement and maximum
duration, and takes precedence over drag on End. There is no velocity test.
A gap between tap and drag distances can deliberately produce no gesture.
Default thresholds are provided only for this new opt-in path: 10 px / 0.25 s tap, 12 px / 0 s drag, and 48 px / 0.5 s swipe. Legacy handling never reads them.
use ferravex_play::input::touch::{GestureError, GestureProfile};
let profile = GestureProfile { tap_max_seconds: 0.4, ..GestureProfile::default() };
profile.validate()?;
assert_eq!(GestureProfile { drag_min_distance: 0.0, ..profile }.validate(),
Err(GestureError::InvalidProfile));Fields§
§tap_max_distance: f32§tap_max_seconds: f64§drag_min_distance: f32§drag_min_seconds: f64§swipe_min_distance: f32§swipe_max_seconds: f64Implementations§
Source§impl GestureProfile
impl GestureProfile
Sourcepub fn validate(self) -> Result<(), GestureError>
pub fn validate(self) -> Result<(), GestureError>
Validate all fields without changing a surface. See the type’s example.
Trait Implementations§
Source§impl Clone for GestureProfile
impl Clone for GestureProfile
Source§fn clone(&self) -> GestureProfile
fn clone(&self) -> GestureProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more