ferroui_base/input/
pull_gesture_event_args.rs1use super::InputElement;
2use crate::interactivity::RoutedEventArgs;
3use crate::{ferro_routed_event_args, Vector};
4use std::sync::atomic::{AtomicI32, Ordering};
5
6static NEXT_ID: AtomicI32 = AtomicI32::new(1);
7
8#[derive(Clone)]
10pub struct PullGestureEventArgs {
11 base: RoutedEventArgs,
12 id: i32,
13 delta: Vector,
14 pull_direction: PullDirection,
15}
16
17ferro_routed_event_args!(PullGestureEventArgs: RoutedEventArgs);
18
19impl PullGestureEventArgs {
20 pub fn new(id: i32, delta: Vector, pull_direction: PullDirection) -> Self {
22 Self {
23 base: RoutedEventArgs::with_event(InputElement::pull_gesture_event()),
24 id,
25 delta,
26 pull_direction,
27 }
28 }
29
30 #[doc(hidden)]
31 pub fn get_next_free_id() -> i32 {
32 NEXT_ID.fetch_add(1, Ordering::Relaxed)
33 }
34
35 #[inline]
37 pub fn id(&self) -> i32 {
38 self.id
39 }
40
41 #[inline]
43 pub fn delta(&self) -> Vector {
44 self.delta
45 }
46
47 #[inline]
49 pub fn pull_direction(&self) -> PullDirection {
50 self.pull_direction
51 }
52}
53
54#[derive(Clone)]
56pub struct PullGestureEndedEventArgs {
57 base: RoutedEventArgs,
58 id: i32,
59 pull_direction: PullDirection,
60}
61
62ferro_routed_event_args!(PullGestureEndedEventArgs: RoutedEventArgs);
63
64impl PullGestureEndedEventArgs {
65 pub fn new(id: i32, pull_direction: PullDirection) -> Self {
67 Self { base: RoutedEventArgs::with_event(InputElement::pull_gesture_ended_event()), id, pull_direction }
68 }
69
70 #[inline]
72 pub fn id(&self) -> i32 {
73 self.id
74 }
75
76 #[inline]
78 pub fn pull_direction(&self) -> PullDirection {
79 self.pull_direction
80 }
81}
82
83#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
85pub enum PullDirection {
86 TopToBottom,
87 BottomToTop,
88 LeftToRight,
89 RightToLeft,
90}