1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIGestureRecognizerState(pub NSInteger);
impl UIGestureRecognizerState {
    #[doc(alias = "UIGestureRecognizerStatePossible")]
    pub const Possible: Self = Self(0);
    #[doc(alias = "UIGestureRecognizerStateBegan")]
    pub const Began: Self = Self(1);
    #[doc(alias = "UIGestureRecognizerStateChanged")]
    pub const Changed: Self = Self(2);
    #[doc(alias = "UIGestureRecognizerStateEnded")]
    pub const Ended: Self = Self(3);
    #[doc(alias = "UIGestureRecognizerStateCancelled")]
    pub const Cancelled: Self = Self(4);
    #[doc(alias = "UIGestureRecognizerStateFailed")]
    pub const Failed: Self = Self(5);
    #[doc(alias = "UIGestureRecognizerStateRecognized")]
    pub const Recognized: Self = Self(UIGestureRecognizerState::Ended.0);
}

unsafe impl Encode for UIGestureRecognizerState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIGestureRecognizerState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIGestureRecognizer;

    unsafe impl ClassType for UIGestureRecognizer {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UIGestureRecognizer {}

extern_methods!(
    unsafe impl UIGestureRecognizer {
        #[method_id(@__retain_semantics Init initWithTarget:action:)]
        pub unsafe fn initWithTarget_action(
            this: Allocated<Self>,
            target: Option<&AnyObject>,
            action: Option<Sel>,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[method(addTarget:action:)]
        pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);

        #[method(removeTarget:action:)]
        pub unsafe fn removeTarget_action(&self, target: Option<&AnyObject>, action: Option<Sel>);

        #[method_id(@__retain_semantics Other delegate)]
        pub fn delegate(&self)
            -> Option<Retained<ProtocolObject<dyn UIGestureRecognizerDelegate>>>;

        #[method(setDelegate:)]
        pub fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UIGestureRecognizerDelegate>>,
        );

        #[method(isEnabled)]
        pub unsafe fn isEnabled(&self) -> bool;

        #[method(setEnabled:)]
        pub unsafe fn setEnabled(&self, enabled: bool);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method_id(@__retain_semantics Other view)]
        pub unsafe fn view(&self) -> Option<Retained<UIView>>;

        #[method(cancelsTouchesInView)]
        pub unsafe fn cancelsTouchesInView(&self) -> bool;

        #[method(setCancelsTouchesInView:)]
        pub unsafe fn setCancelsTouchesInView(&self, cancels_touches_in_view: bool);

        #[method(delaysTouchesBegan)]
        pub unsafe fn delaysTouchesBegan(&self) -> bool;

        #[method(setDelaysTouchesBegan:)]
        pub unsafe fn setDelaysTouchesBegan(&self, delays_touches_began: bool);

        #[method(delaysTouchesEnded)]
        pub unsafe fn delaysTouchesEnded(&self) -> bool;

        #[method(setDelaysTouchesEnded:)]
        pub unsafe fn setDelaysTouchesEnded(&self, delays_touches_ended: bool);

        #[method_id(@__retain_semantics Other allowedTouchTypes)]
        pub unsafe fn allowedTouchTypes(&self) -> Retained<NSArray<NSNumber>>;

        #[method(setAllowedTouchTypes:)]
        pub unsafe fn setAllowedTouchTypes(&self, allowed_touch_types: &NSArray<NSNumber>);

        #[method_id(@__retain_semantics Other allowedPressTypes)]
        pub unsafe fn allowedPressTypes(&self) -> Retained<NSArray<NSNumber>>;

        #[method(setAllowedPressTypes:)]
        pub unsafe fn setAllowedPressTypes(&self, allowed_press_types: &NSArray<NSNumber>);

        #[method(requiresExclusiveTouchType)]
        pub unsafe fn requiresExclusiveTouchType(&self) -> bool;

        #[method(setRequiresExclusiveTouchType:)]
        pub unsafe fn setRequiresExclusiveTouchType(&self, requires_exclusive_touch_type: bool);

        #[method(requireGestureRecognizerToFail:)]
        pub unsafe fn requireGestureRecognizerToFail(
            &self,
            other_gesture_recognizer: &UIGestureRecognizer,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method(locationInView:)]
        pub unsafe fn locationInView(&self, view: Option<&UIView>) -> CGPoint;

        #[method(numberOfTouches)]
        pub unsafe fn numberOfTouches(&self) -> NSUInteger;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method(locationOfTouch:inView:)]
        pub unsafe fn locationOfTouch_inView(
            &self,
            touch_index: NSUInteger,
            view: Option<&UIView>,
        ) -> CGPoint;

        #[method_id(@__retain_semantics Other name)]
        pub unsafe fn name(&self) -> Option<Retained<NSString>>;

        #[method(setName:)]
        pub unsafe fn setName(&self, name: Option<&NSString>);

        #[cfg(feature = "UICommand")]
        #[method(modifierFlags)]
        pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;

        #[cfg(feature = "UIEvent")]
        #[method(buttonMask)]
        pub unsafe fn buttonMask(&self) -> UIEventButtonMask;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIGestureRecognizer {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_protocol!(
    pub unsafe trait UIGestureRecognizerDelegate:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[optional]
        #[method(gestureRecognizerShouldBegin:)]
        unsafe fn gestureRecognizerShouldBegin(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
        ) -> bool;

        #[optional]
        #[method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]
        unsafe fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            other_gesture_recognizer: &UIGestureRecognizer,
        ) -> bool;

        #[optional]
        #[method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:)]
        unsafe fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            other_gesture_recognizer: &UIGestureRecognizer,
        ) -> bool;

        #[optional]
        #[method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:)]
        unsafe fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            other_gesture_recognizer: &UIGestureRecognizer,
        ) -> bool;

        #[cfg(feature = "UITouch")]
        #[optional]
        #[method(gestureRecognizer:shouldReceiveTouch:)]
        unsafe fn gestureRecognizer_shouldReceiveTouch(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            touch: &UITouch,
        ) -> bool;

        #[cfg(feature = "UIPress")]
        #[optional]
        #[method(gestureRecognizer:shouldReceivePress:)]
        unsafe fn gestureRecognizer_shouldReceivePress(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            press: &UIPress,
        ) -> bool;

        #[cfg(feature = "UIEvent")]
        #[optional]
        #[method(gestureRecognizer:shouldReceiveEvent:)]
        unsafe fn gestureRecognizer_shouldReceiveEvent(
            &self,
            gesture_recognizer: &UIGestureRecognizer,
            event: &UIEvent,
        ) -> bool;
    }

    unsafe impl ProtocolType for dyn UIGestureRecognizerDelegate {}
);