objc2_ui_kit/generated/
UIGestureRecognizer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigesturerecognizerstate?language=objc)
13// NS_ENUM
14#[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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigesturerecognizer?language=objc)
44    #[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        /// # Safety
57        ///
58        /// - `target` should be of the correct type.
59        /// - `action` must be a valid selector.
60        #[unsafe(method(initWithTarget:action:))]
61        #[unsafe(method_family = init)]
62        pub unsafe fn initWithTarget_action(
63            this: Allocated<Self>,
64            target: Option<&AnyObject>,
65            action: Option<Sel>,
66        ) -> Retained<Self>;
67
68        #[unsafe(method(init))]
69        #[unsafe(method_family = init)]
70        pub fn init(this: Allocated<Self>) -> Retained<Self>;
71
72        /// # Safety
73        ///
74        /// `coder` possibly has further requirements.
75        #[unsafe(method(initWithCoder:))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn initWithCoder(
78            this: Allocated<Self>,
79            coder: &NSCoder,
80        ) -> Option<Retained<Self>>;
81
82        /// # Safety
83        ///
84        /// - `target` should be of the correct type.
85        /// - `action` must be a valid selector.
86        #[unsafe(method(addTarget:action:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
89
90        /// # Safety
91        ///
92        /// - `target` should be of the correct type.
93        /// - `action` must be a valid selector.
94        #[unsafe(method(removeTarget:action:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn removeTarget_action(&self, target: Option<&AnyObject>, action: Option<Sel>);
97
98        #[unsafe(method(delegate))]
99        #[unsafe(method_family = none)]
100        pub fn delegate(&self)
101            -> Option<Retained<ProtocolObject<dyn UIGestureRecognizerDelegate>>>;
102
103        /// Setter for [`delegate`][Self::delegate].
104        ///
105        /// This is a [weak property][objc2::topics::weak_property].
106        #[unsafe(method(setDelegate:))]
107        #[unsafe(method_family = none)]
108        pub fn setDelegate(
109            &self,
110            delegate: Option<&ProtocolObject<dyn UIGestureRecognizerDelegate>>,
111        );
112
113        #[unsafe(method(isEnabled))]
114        #[unsafe(method_family = none)]
115        pub fn isEnabled(&self) -> bool;
116
117        /// Setter for [`isEnabled`][Self::isEnabled].
118        #[unsafe(method(setEnabled:))]
119        #[unsafe(method_family = none)]
120        pub fn setEnabled(&self, enabled: bool);
121
122        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
123        #[unsafe(method(view))]
124        #[unsafe(method_family = none)]
125        pub fn view(&self) -> Option<Retained<UIView>>;
126
127        #[unsafe(method(cancelsTouchesInView))]
128        #[unsafe(method_family = none)]
129        pub fn cancelsTouchesInView(&self) -> bool;
130
131        /// Setter for [`cancelsTouchesInView`][Self::cancelsTouchesInView].
132        #[unsafe(method(setCancelsTouchesInView:))]
133        #[unsafe(method_family = none)]
134        pub fn setCancelsTouchesInView(&self, cancels_touches_in_view: bool);
135
136        #[unsafe(method(delaysTouchesBegan))]
137        #[unsafe(method_family = none)]
138        pub fn delaysTouchesBegan(&self) -> bool;
139
140        /// Setter for [`delaysTouchesBegan`][Self::delaysTouchesBegan].
141        #[unsafe(method(setDelaysTouchesBegan:))]
142        #[unsafe(method_family = none)]
143        pub fn setDelaysTouchesBegan(&self, delays_touches_began: bool);
144
145        #[unsafe(method(delaysTouchesEnded))]
146        #[unsafe(method_family = none)]
147        pub fn delaysTouchesEnded(&self) -> bool;
148
149        /// Setter for [`delaysTouchesEnded`][Self::delaysTouchesEnded].
150        #[unsafe(method(setDelaysTouchesEnded:))]
151        #[unsafe(method_family = none)]
152        pub fn setDelaysTouchesEnded(&self, delays_touches_ended: bool);
153
154        #[unsafe(method(allowedTouchTypes))]
155        #[unsafe(method_family = none)]
156        pub fn allowedTouchTypes(&self) -> Retained<NSArray<NSNumber>>;
157
158        /// Setter for [`allowedTouchTypes`][Self::allowedTouchTypes].
159        ///
160        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
161        #[unsafe(method(setAllowedTouchTypes:))]
162        #[unsafe(method_family = none)]
163        pub fn setAllowedTouchTypes(&self, allowed_touch_types: &NSArray<NSNumber>);
164
165        #[unsafe(method(allowedPressTypes))]
166        #[unsafe(method_family = none)]
167        pub fn allowedPressTypes(&self) -> Retained<NSArray<NSNumber>>;
168
169        /// Setter for [`allowedPressTypes`][Self::allowedPressTypes].
170        ///
171        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
172        #[unsafe(method(setAllowedPressTypes:))]
173        #[unsafe(method_family = none)]
174        pub fn setAllowedPressTypes(&self, allowed_press_types: &NSArray<NSNumber>);
175
176        #[unsafe(method(requiresExclusiveTouchType))]
177        #[unsafe(method_family = none)]
178        pub fn requiresExclusiveTouchType(&self) -> bool;
179
180        /// Setter for [`requiresExclusiveTouchType`][Self::requiresExclusiveTouchType].
181        #[unsafe(method(setRequiresExclusiveTouchType:))]
182        #[unsafe(method_family = none)]
183        pub fn setRequiresExclusiveTouchType(&self, requires_exclusive_touch_type: bool);
184
185        #[unsafe(method(requireGestureRecognizerToFail:))]
186        #[unsafe(method_family = none)]
187        pub fn requireGestureRecognizerToFail(
188            &self,
189            other_gesture_recognizer: &UIGestureRecognizer,
190        );
191
192        #[cfg(all(
193            feature = "UIResponder",
194            feature = "UIView",
195            feature = "objc2-core-foundation"
196        ))]
197        #[unsafe(method(locationInView:))]
198        #[unsafe(method_family = none)]
199        pub fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
200
201        #[unsafe(method(numberOfTouches))]
202        #[unsafe(method_family = none)]
203        pub fn numberOfTouches(&self) -> NSUInteger;
204
205        #[cfg(all(
206            feature = "UIResponder",
207            feature = "UIView",
208            feature = "objc2-core-foundation"
209        ))]
210        #[unsafe(method(locationOfTouch:inView:))]
211        #[unsafe(method_family = none)]
212        pub fn locationOfTouch_inView(
213            &self,
214            touch_index: NSUInteger,
215            view: Option<&UIView>,
216        ) -> CGPoint;
217
218        #[unsafe(method(name))]
219        #[unsafe(method_family = none)]
220        pub fn name(&self) -> Option<Retained<NSString>>;
221
222        /// Setter for [`name`][Self::name].
223        ///
224        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
225        #[unsafe(method(setName:))]
226        #[unsafe(method_family = none)]
227        pub fn setName(&self, name: Option<&NSString>);
228
229        #[cfg(feature = "UICommand")]
230        #[unsafe(method(modifierFlags))]
231        #[unsafe(method_family = none)]
232        pub fn modifierFlags(&self) -> UIKeyModifierFlags;
233
234        #[cfg(feature = "UIEvent")]
235        #[unsafe(method(buttonMask))]
236        #[unsafe(method_family = none)]
237        pub fn buttonMask(&self) -> UIEventButtonMask;
238    );
239}
240
241/// Methods declared on superclass `NSObject`.
242impl UIGestureRecognizer {
243    extern_methods!(
244        #[unsafe(method(new))]
245        #[unsafe(method_family = new)]
246        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
247    );
248}
249
250extern_protocol!(
251    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate?language=objc)
252    pub unsafe trait UIGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
253        #[optional]
254        #[unsafe(method(gestureRecognizerShouldBegin:))]
255        #[unsafe(method_family = none)]
256        fn gestureRecognizerShouldBegin(&self, gesture_recognizer: &UIGestureRecognizer) -> bool;
257
258        #[optional]
259        #[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
260        #[unsafe(method_family = none)]
261        fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
262            &self,
263            gesture_recognizer: &UIGestureRecognizer,
264            other_gesture_recognizer: &UIGestureRecognizer,
265        ) -> bool;
266
267        #[optional]
268        #[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
269        #[unsafe(method_family = none)]
270        fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
271            &self,
272            gesture_recognizer: &UIGestureRecognizer,
273            other_gesture_recognizer: &UIGestureRecognizer,
274        ) -> bool;
275
276        #[optional]
277        #[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
278        #[unsafe(method_family = none)]
279        fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
280            &self,
281            gesture_recognizer: &UIGestureRecognizer,
282            other_gesture_recognizer: &UIGestureRecognizer,
283        ) -> bool;
284
285        #[cfg(feature = "UITouch")]
286        #[optional]
287        #[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
288        #[unsafe(method_family = none)]
289        fn gestureRecognizer_shouldReceiveTouch(
290            &self,
291            gesture_recognizer: &UIGestureRecognizer,
292            touch: &UITouch,
293        ) -> bool;
294
295        #[cfg(feature = "UIPress")]
296        #[optional]
297        #[unsafe(method(gestureRecognizer:shouldReceivePress:))]
298        #[unsafe(method_family = none)]
299        fn gestureRecognizer_shouldReceivePress(
300            &self,
301            gesture_recognizer: &UIGestureRecognizer,
302            press: &UIPress,
303        ) -> bool;
304
305        #[cfg(feature = "UIEvent")]
306        #[optional]
307        #[unsafe(method(gestureRecognizer:shouldReceiveEvent:))]
308        #[unsafe(method_family = none)]
309        fn gestureRecognizer_shouldReceiveEvent(
310            &self,
311            gesture_recognizer: &UIGestureRecognizer,
312            event: &UIEvent,
313        ) -> bool;
314    }
315);