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
//! 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 UITouchPhase(pub NSInteger);
impl UITouchPhase {
    #[doc(alias = "UITouchPhaseBegan")]
    pub const Began: Self = Self(0);
    #[doc(alias = "UITouchPhaseMoved")]
    pub const Moved: Self = Self(1);
    #[doc(alias = "UITouchPhaseStationary")]
    pub const Stationary: Self = Self(2);
    #[doc(alias = "UITouchPhaseEnded")]
    pub const Ended: Self = Self(3);
    #[doc(alias = "UITouchPhaseCancelled")]
    pub const Cancelled: Self = Self(4);
    #[doc(alias = "UITouchPhaseRegionEntered")]
    pub const RegionEntered: Self = Self(5);
    #[doc(alias = "UITouchPhaseRegionMoved")]
    pub const RegionMoved: Self = Self(6);
    #[doc(alias = "UITouchPhaseRegionExited")]
    pub const RegionExited: Self = Self(7);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIForceTouchCapability(pub NSInteger);
impl UIForceTouchCapability {
    #[doc(alias = "UIForceTouchCapabilityUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "UIForceTouchCapabilityUnavailable")]
    pub const Unavailable: Self = Self(1);
    #[doc(alias = "UIForceTouchCapabilityAvailable")]
    pub const Available: Self = Self(2);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITouchType(pub NSInteger);
impl UITouchType {
    #[doc(alias = "UITouchTypeDirect")]
    pub const Direct: Self = Self(0);
    #[doc(alias = "UITouchTypeIndirect")]
    pub const Indirect: Self = Self(1);
    #[doc(alias = "UITouchTypePencil")]
    pub const Pencil: Self = Self(2);
    #[doc(alias = "UITouchTypeStylus")]
    pub const Stylus: Self = Self(UITouchType::Pencil.0);
    #[doc(alias = "UITouchTypeIndirectPointer")]
    pub const IndirectPointer: Self = Self(3);
}

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

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

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITouchProperties(pub NSInteger);
bitflags::bitflags! {
    impl UITouchProperties: NSInteger {
        const UITouchPropertyForce = 1<<0;
        const UITouchPropertyAzimuth = 1<<1;
        const UITouchPropertyAltitude = 1<<2;
        const UITouchPropertyLocation = 1<<3;
        const UITouchPropertyRoll = 1<<4;
    }
}

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

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

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

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

unsafe impl NSObjectProtocol for UITouch {}

extern_methods!(
    unsafe impl UITouch {
        #[method(timestamp)]
        pub fn timestamp(&self) -> NSTimeInterval;

        #[method(phase)]
        pub fn phase(&self) -> UITouchPhase;

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

        #[method(type)]
        pub fn r#type(&self) -> UITouchType;

        #[method(majorRadius)]
        pub unsafe fn majorRadius(&self) -> CGFloat;

        #[method(majorRadiusTolerance)]
        pub unsafe fn majorRadiusTolerance(&self) -> CGFloat;

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

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

        #[cfg(feature = "UIGestureRecognizer")]
        #[method_id(@__retain_semantics Other gestureRecognizers)]
        pub unsafe fn gestureRecognizers(&self) -> Option<Retained<NSArray<UIGestureRecognizer>>>;

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

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

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

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

        #[method(force)]
        pub fn force(&self) -> CGFloat;

        #[method(maximumPossibleForce)]
        pub fn maximumPossibleForce(&self) -> CGFloat;

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

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

        #[method(altitudeAngle)]
        pub fn altitudeAngle(&self) -> CGFloat;

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

        #[method(estimatedProperties)]
        pub unsafe fn estimatedProperties(&self) -> UITouchProperties;

        #[method(estimatedPropertiesExpectingUpdates)]
        pub unsafe fn estimatedPropertiesExpectingUpdates(&self) -> UITouchProperties;

        #[method(rollAngle)]
        pub fn rollAngle(&self) -> CGFloat;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UITouch {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);