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
50unsafe impl NSObjectProtocol for UIGestureRecognizer {}
51
52impl UIGestureRecognizer {
53 extern_methods!(
54 #[unsafe(method(initWithTarget:action:))]
55 #[unsafe(method_family = init)]
56 pub unsafe fn initWithTarget_action(
57 this: Allocated<Self>,
58 target: Option<&AnyObject>,
59 action: Option<Sel>,
60 ) -> Retained<Self>;
61
62 #[unsafe(method(init))]
63 #[unsafe(method_family = init)]
64 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
65
66 #[unsafe(method(initWithCoder:))]
67 #[unsafe(method_family = init)]
68 pub unsafe fn initWithCoder(
69 this: Allocated<Self>,
70 coder: &NSCoder,
71 ) -> Option<Retained<Self>>;
72
73 #[unsafe(method(addTarget:action:))]
74 #[unsafe(method_family = none)]
75 pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
76
77 #[unsafe(method(removeTarget:action:))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn removeTarget_action(&self, target: Option<&AnyObject>, action: Option<Sel>);
80
81 #[unsafe(method(delegate))]
82 #[unsafe(method_family = none)]
83 pub fn delegate(&self)
84 -> Option<Retained<ProtocolObject<dyn UIGestureRecognizerDelegate>>>;
85
86 #[unsafe(method(setDelegate:))]
89 #[unsafe(method_family = none)]
90 pub fn setDelegate(
91 &self,
92 delegate: Option<&ProtocolObject<dyn UIGestureRecognizerDelegate>>,
93 );
94
95 #[unsafe(method(isEnabled))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn isEnabled(&self) -> bool;
98
99 #[unsafe(method(setEnabled:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn setEnabled(&self, enabled: bool);
103
104 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
105 #[unsafe(method(view))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn view(&self) -> Option<Retained<UIView>>;
108
109 #[unsafe(method(cancelsTouchesInView))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn cancelsTouchesInView(&self) -> bool;
112
113 #[unsafe(method(setCancelsTouchesInView:))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn setCancelsTouchesInView(&self, cancels_touches_in_view: bool);
117
118 #[unsafe(method(delaysTouchesBegan))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn delaysTouchesBegan(&self) -> bool;
121
122 #[unsafe(method(setDelaysTouchesBegan:))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn setDelaysTouchesBegan(&self, delays_touches_began: bool);
126
127 #[unsafe(method(delaysTouchesEnded))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn delaysTouchesEnded(&self) -> bool;
130
131 #[unsafe(method(setDelaysTouchesEnded:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn setDelaysTouchesEnded(&self, delays_touches_ended: bool);
135
136 #[unsafe(method(allowedTouchTypes))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn allowedTouchTypes(&self) -> Retained<NSArray<NSNumber>>;
139
140 #[unsafe(method(setAllowedTouchTypes:))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn setAllowedTouchTypes(&self, allowed_touch_types: &NSArray<NSNumber>);
144
145 #[unsafe(method(allowedPressTypes))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn allowedPressTypes(&self) -> Retained<NSArray<NSNumber>>;
148
149 #[unsafe(method(setAllowedPressTypes:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn setAllowedPressTypes(&self, allowed_press_types: &NSArray<NSNumber>);
153
154 #[unsafe(method(requiresExclusiveTouchType))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn requiresExclusiveTouchType(&self) -> bool;
157
158 #[unsafe(method(setRequiresExclusiveTouchType:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setRequiresExclusiveTouchType(&self, requires_exclusive_touch_type: bool);
162
163 #[unsafe(method(requireGestureRecognizerToFail:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn requireGestureRecognizerToFail(
166 &self,
167 other_gesture_recognizer: &UIGestureRecognizer,
168 );
169
170 #[cfg(all(
171 feature = "UIResponder",
172 feature = "UIView",
173 feature = "objc2-core-foundation"
174 ))]
175 #[unsafe(method(locationInView:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
178
179 #[unsafe(method(numberOfTouches))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn numberOfTouches(&self) -> NSUInteger;
182
183 #[cfg(all(
184 feature = "UIResponder",
185 feature = "UIView",
186 feature = "objc2-core-foundation"
187 ))]
188 #[unsafe(method(locationOfTouch:inView:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn locationOfTouch_inView(
191 &self,
192 touch_index: NSUInteger,
193 view: Option<&UIView>,
194 ) -> CGPoint;
195
196 #[unsafe(method(name))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
199
200 #[unsafe(method(setName:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn setName(&self, name: Option<&NSString>);
204
205 #[cfg(feature = "UICommand")]
206 #[unsafe(method(modifierFlags))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
209
210 #[cfg(feature = "UIEvent")]
211 #[unsafe(method(buttonMask))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn buttonMask(&self) -> UIEventButtonMask;
214 );
215}
216
217impl UIGestureRecognizer {
219 extern_methods!(
220 #[unsafe(method(new))]
221 #[unsafe(method_family = new)]
222 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
223 );
224}
225
226extern_protocol!(
227 pub unsafe trait UIGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
229 #[optional]
230 #[unsafe(method(gestureRecognizerShouldBegin:))]
231 #[unsafe(method_family = none)]
232 unsafe fn gestureRecognizerShouldBegin(
233 &self,
234 gesture_recognizer: &UIGestureRecognizer,
235 ) -> bool;
236
237 #[optional]
238 #[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
239 #[unsafe(method_family = none)]
240 unsafe fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
241 &self,
242 gesture_recognizer: &UIGestureRecognizer,
243 other_gesture_recognizer: &UIGestureRecognizer,
244 ) -> bool;
245
246 #[optional]
247 #[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
248 #[unsafe(method_family = none)]
249 unsafe fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
250 &self,
251 gesture_recognizer: &UIGestureRecognizer,
252 other_gesture_recognizer: &UIGestureRecognizer,
253 ) -> bool;
254
255 #[optional]
256 #[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
257 #[unsafe(method_family = none)]
258 unsafe fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
259 &self,
260 gesture_recognizer: &UIGestureRecognizer,
261 other_gesture_recognizer: &UIGestureRecognizer,
262 ) -> bool;
263
264 #[cfg(feature = "UITouch")]
265 #[optional]
266 #[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
267 #[unsafe(method_family = none)]
268 unsafe fn gestureRecognizer_shouldReceiveTouch(
269 &self,
270 gesture_recognizer: &UIGestureRecognizer,
271 touch: &UITouch,
272 ) -> bool;
273
274 #[cfg(feature = "UIPress")]
275 #[optional]
276 #[unsafe(method(gestureRecognizer:shouldReceivePress:))]
277 #[unsafe(method_family = none)]
278 unsafe fn gestureRecognizer_shouldReceivePress(
279 &self,
280 gesture_recognizer: &UIGestureRecognizer,
281 press: &UIPress,
282 ) -> bool;
283
284 #[cfg(feature = "UIEvent")]
285 #[optional]
286 #[unsafe(method(gestureRecognizer:shouldReceiveEvent:))]
287 #[unsafe(method_family = none)]
288 unsafe fn gestureRecognizer_shouldReceiveEvent(
289 &self,
290 gesture_recognizer: &UIGestureRecognizer,
291 event: &UIEvent,
292 ) -> bool;
293 }
294);