objc2_ui_kit/generated/
UISwipeGestureRecognizer.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswipegesturerecognizerdirection?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UISwipeGestureRecognizerDirection(pub NSUInteger);
15bitflags::bitflags! {
16    impl UISwipeGestureRecognizerDirection: NSUInteger {
17        #[doc(alias = "UISwipeGestureRecognizerDirectionRight")]
18        const Right = 1<<0;
19        #[doc(alias = "UISwipeGestureRecognizerDirectionLeft")]
20        const Left = 1<<1;
21        #[doc(alias = "UISwipeGestureRecognizerDirectionUp")]
22        const Up = 1<<2;
23        #[doc(alias = "UISwipeGestureRecognizerDirectionDown")]
24        const Down = 1<<3;
25    }
26}
27
28unsafe impl Encode for UISwipeGestureRecognizerDirection {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UISwipeGestureRecognizerDirection {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswipegesturerecognizer?language=objc)
38    #[unsafe(super(UIGestureRecognizer, NSObject))]
39    #[thread_kind = MainThreadOnly]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    #[cfg(feature = "UIGestureRecognizer")]
42    pub struct UISwipeGestureRecognizer;
43);
44
45#[cfg(feature = "UIGestureRecognizer")]
46extern_conformance!(
47    unsafe impl NSObjectProtocol for UISwipeGestureRecognizer {}
48);
49
50#[cfg(feature = "UIGestureRecognizer")]
51impl UISwipeGestureRecognizer {
52    extern_methods!(
53        #[unsafe(method(numberOfTouchesRequired))]
54        #[unsafe(method_family = none)]
55        pub fn numberOfTouchesRequired(&self) -> NSUInteger;
56
57        /// Setter for [`numberOfTouchesRequired`][Self::numberOfTouchesRequired].
58        #[unsafe(method(setNumberOfTouchesRequired:))]
59        #[unsafe(method_family = none)]
60        pub fn setNumberOfTouchesRequired(&self, number_of_touches_required: NSUInteger);
61
62        #[unsafe(method(direction))]
63        #[unsafe(method_family = none)]
64        pub fn direction(&self) -> UISwipeGestureRecognizerDirection;
65
66        /// Setter for [`direction`][Self::direction].
67        #[unsafe(method(setDirection:))]
68        #[unsafe(method_family = none)]
69        pub fn setDirection(&self, direction: UISwipeGestureRecognizerDirection);
70    );
71}
72
73/// Methods declared on superclass `UIGestureRecognizer`.
74#[cfg(feature = "UIGestureRecognizer")]
75impl UISwipeGestureRecognizer {
76    extern_methods!(
77        /// # Safety
78        ///
79        /// - `target` should be of the correct type.
80        /// - `action` must be a valid selector.
81        #[unsafe(method(initWithTarget:action:))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn initWithTarget_action(
84            this: Allocated<Self>,
85            target: Option<&AnyObject>,
86            action: Option<Sel>,
87        ) -> Retained<Self>;
88
89        #[unsafe(method(init))]
90        #[unsafe(method_family = init)]
91        pub fn init(this: Allocated<Self>) -> Retained<Self>;
92
93        /// # Safety
94        ///
95        /// `coder` possibly has further requirements.
96        #[unsafe(method(initWithCoder:))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn initWithCoder(
99            this: Allocated<Self>,
100            coder: &NSCoder,
101        ) -> Option<Retained<Self>>;
102    );
103}
104
105/// Methods declared on superclass `NSObject`.
106#[cfg(feature = "UIGestureRecognizer")]
107impl UISwipeGestureRecognizer {
108    extern_methods!(
109        #[unsafe(method(new))]
110        #[unsafe(method_family = new)]
111        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
112    );
113}