objc2_ui_kit/generated/
UIGestureRecognizer.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIGestureRecognizerState(pub NSInteger);
17impl UIGestureRecognizerState {
18 #[doc(alias = "UIGestureRecognizerStatePossible")]
19 pub const Possible: Self = Self(0);
20 #[doc(alias = "UIGestureRecognizerStateBegan")]
21 pub const Began: Self = Self(1);
22 #[doc(alias = "UIGestureRecognizerStateChanged")]
23 pub const Changed: Self = Self(2);
24 #[doc(alias = "UIGestureRecognizerStateEnded")]
25 pub const Ended: Self = Self(3);
26 #[doc(alias = "UIGestureRecognizerStateCancelled")]
27 pub const Cancelled: Self = Self(4);
28 #[doc(alias = "UIGestureRecognizerStateFailed")]
29 pub const Failed: Self = Self(5);
30 #[doc(alias = "UIGestureRecognizerStateRecognized")]
31 pub const Recognized: Self = Self(UIGestureRecognizerState::Ended.0);
32}
33
34unsafe impl Encode for UIGestureRecognizerState {
35 const ENCODING: Encoding = NSInteger::ENCODING;
36}
37
38unsafe impl RefEncode for UIGestureRecognizerState {
39 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43 #[unsafe(super(NSObject))]
45 #[thread_kind = MainThreadOnly]
46 #[derive(Debug, PartialEq, Eq, Hash)]
47 pub struct UIGestureRecognizer;
48);
49
50extern_conformance!(
51 unsafe impl NSObjectProtocol for UIGestureRecognizer {}
52);
53
54impl UIGestureRecognizer {
55 extern_methods!(
56 #[unsafe(method(initWithTarget:action:))]
57 #[unsafe(method_family = init)]
58 pub unsafe fn initWithTarget_action(
59 this: Allocated<Self>,
60 target: Option<&AnyObject>,
61 action: Option<Sel>,
62 ) -> Retained<Self>;
63
64 #[unsafe(method(init))]
65 #[unsafe(method_family = init)]
66 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
67
68 #[unsafe(method(initWithCoder:))]
69 #[unsafe(method_family = init)]
70 pub unsafe fn initWithCoder(
71 this: Allocated<Self>,
72 coder: &NSCoder,
73 ) -> Option<Retained<Self>>;
74
75 #[unsafe(method(addTarget:action:))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
78
79 #[unsafe(method(removeTarget:action:))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn removeTarget_action(&self, target: Option<&AnyObject>, action: Option<Sel>);
82
83 #[unsafe(method(delegate))]
84 #[unsafe(method_family = none)]
85 pub fn delegate(&self)
86 -> Option<Retained<ProtocolObject<dyn UIGestureRecognizerDelegate>>>;
87
88 #[unsafe(method(setDelegate:))]
91 #[unsafe(method_family = none)]
92 pub fn setDelegate(
93 &self,
94 delegate: Option<&ProtocolObject<dyn UIGestureRecognizerDelegate>>,
95 );
96
97 #[unsafe(method(isEnabled))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn isEnabled(&self) -> bool;
100
101 #[unsafe(method(setEnabled:))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn setEnabled(&self, enabled: bool);
105
106 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
107 #[unsafe(method(view))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn view(&self) -> Option<Retained<UIView>>;
110
111 #[unsafe(method(cancelsTouchesInView))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn cancelsTouchesInView(&self) -> bool;
114
115 #[unsafe(method(setCancelsTouchesInView:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn setCancelsTouchesInView(&self, cancels_touches_in_view: bool);
119
120 #[unsafe(method(delaysTouchesBegan))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn delaysTouchesBegan(&self) -> bool;
123
124 #[unsafe(method(setDelaysTouchesBegan:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn setDelaysTouchesBegan(&self, delays_touches_began: bool);
128
129 #[unsafe(method(delaysTouchesEnded))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn delaysTouchesEnded(&self) -> bool;
132
133 #[unsafe(method(setDelaysTouchesEnded:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn setDelaysTouchesEnded(&self, delays_touches_ended: bool);
137
138 #[unsafe(method(allowedTouchTypes))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn allowedTouchTypes(&self) -> Retained<NSArray<NSNumber>>;
141
142 #[unsafe(method(setAllowedTouchTypes:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setAllowedTouchTypes(&self, allowed_touch_types: &NSArray<NSNumber>);
146
147 #[unsafe(method(allowedPressTypes))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn allowedPressTypes(&self) -> Retained<NSArray<NSNumber>>;
150
151 #[unsafe(method(setAllowedPressTypes:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn setAllowedPressTypes(&self, allowed_press_types: &NSArray<NSNumber>);
155
156 #[unsafe(method(requiresExclusiveTouchType))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn requiresExclusiveTouchType(&self) -> bool;
159
160 #[unsafe(method(setRequiresExclusiveTouchType:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn setRequiresExclusiveTouchType(&self, requires_exclusive_touch_type: bool);
164
165 #[unsafe(method(requireGestureRecognizerToFail:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn requireGestureRecognizerToFail(
168 &self,
169 other_gesture_recognizer: &UIGestureRecognizer,
170 );
171
172 #[cfg(all(
173 feature = "UIResponder",
174 feature = "UIView",
175 feature = "objc2-core-foundation"
176 ))]
177 #[unsafe(method(locationInView:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
180
181 #[unsafe(method(numberOfTouches))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn numberOfTouches(&self) -> NSUInteger;
184
185 #[cfg(all(
186 feature = "UIResponder",
187 feature = "UIView",
188 feature = "objc2-core-foundation"
189 ))]
190 #[unsafe(method(locationOfTouch:inView:))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn locationOfTouch_inView(
193 &self,
194 touch_index: NSUInteger,
195 view: Option<&UIView>,
196 ) -> CGPoint;
197
198 #[unsafe(method(name))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
201
202 #[unsafe(method(setName:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn setName(&self, name: Option<&NSString>);
206
207 #[cfg(feature = "UICommand")]
208 #[unsafe(method(modifierFlags))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
211
212 #[cfg(feature = "UIEvent")]
213 #[unsafe(method(buttonMask))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn buttonMask(&self) -> UIEventButtonMask;
216 );
217}
218
219impl UIGestureRecognizer {
221 extern_methods!(
222 #[unsafe(method(new))]
223 #[unsafe(method_family = new)]
224 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
225 );
226}
227
228extern_protocol!(
229 pub unsafe trait UIGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
231 #[optional]
232 #[unsafe(method(gestureRecognizerShouldBegin:))]
233 #[unsafe(method_family = none)]
234 unsafe fn gestureRecognizerShouldBegin(
235 &self,
236 gesture_recognizer: &UIGestureRecognizer,
237 ) -> bool;
238
239 #[optional]
240 #[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
241 #[unsafe(method_family = none)]
242 unsafe fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
243 &self,
244 gesture_recognizer: &UIGestureRecognizer,
245 other_gesture_recognizer: &UIGestureRecognizer,
246 ) -> bool;
247
248 #[optional]
249 #[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
250 #[unsafe(method_family = none)]
251 unsafe fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
252 &self,
253 gesture_recognizer: &UIGestureRecognizer,
254 other_gesture_recognizer: &UIGestureRecognizer,
255 ) -> bool;
256
257 #[optional]
258 #[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
259 #[unsafe(method_family = none)]
260 unsafe fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
261 &self,
262 gesture_recognizer: &UIGestureRecognizer,
263 other_gesture_recognizer: &UIGestureRecognizer,
264 ) -> bool;
265
266 #[cfg(feature = "UITouch")]
267 #[optional]
268 #[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
269 #[unsafe(method_family = none)]
270 unsafe fn gestureRecognizer_shouldReceiveTouch(
271 &self,
272 gesture_recognizer: &UIGestureRecognizer,
273 touch: &UITouch,
274 ) -> bool;
275
276 #[cfg(feature = "UIPress")]
277 #[optional]
278 #[unsafe(method(gestureRecognizer:shouldReceivePress:))]
279 #[unsafe(method_family = none)]
280 unsafe fn gestureRecognizer_shouldReceivePress(
281 &self,
282 gesture_recognizer: &UIGestureRecognizer,
283 press: &UIPress,
284 ) -> bool;
285
286 #[cfg(feature = "UIEvent")]
287 #[optional]
288 #[unsafe(method(gestureRecognizer:shouldReceiveEvent:))]
289 #[unsafe(method_family = none)]
290 unsafe fn gestureRecognizer_shouldReceiveEvent(
291 &self,
292 gesture_recognizer: &UIGestureRecognizer,
293 event: &UIEvent,
294 ) -> bool;
295 }
296);