objc2_ui_kit/generated/
UITouch.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7use objc2_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitouchphase?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct UITouchPhase(pub NSInteger);
16impl UITouchPhase {
17    #[doc(alias = "UITouchPhaseBegan")]
18    pub const Began: Self = Self(0);
19    #[doc(alias = "UITouchPhaseMoved")]
20    pub const Moved: Self = Self(1);
21    #[doc(alias = "UITouchPhaseStationary")]
22    pub const Stationary: Self = Self(2);
23    #[doc(alias = "UITouchPhaseEnded")]
24    pub const Ended: Self = Self(3);
25    #[doc(alias = "UITouchPhaseCancelled")]
26    pub const Cancelled: Self = Self(4);
27    #[doc(alias = "UITouchPhaseRegionEntered")]
28    pub const RegionEntered: Self = Self(5);
29    #[doc(alias = "UITouchPhaseRegionMoved")]
30    pub const RegionMoved: Self = Self(6);
31    #[doc(alias = "UITouchPhaseRegionExited")]
32    pub const RegionExited: Self = Self(7);
33}
34
35unsafe impl Encode for UITouchPhase {
36    const ENCODING: Encoding = NSInteger::ENCODING;
37}
38
39unsafe impl RefEncode for UITouchPhase {
40    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
41}
42
43/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiforcetouchcapability?language=objc)
44// NS_ENUM
45#[repr(transparent)]
46#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
47pub struct UIForceTouchCapability(pub NSInteger);
48impl UIForceTouchCapability {
49    #[doc(alias = "UIForceTouchCapabilityUnknown")]
50    pub const Unknown: Self = Self(0);
51    #[doc(alias = "UIForceTouchCapabilityUnavailable")]
52    pub const Unavailable: Self = Self(1);
53    #[doc(alias = "UIForceTouchCapabilityAvailable")]
54    pub const Available: Self = Self(2);
55}
56
57unsafe impl Encode for UIForceTouchCapability {
58    const ENCODING: Encoding = NSInteger::ENCODING;
59}
60
61unsafe impl RefEncode for UIForceTouchCapability {
62    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
63}
64
65/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitouchtype?language=objc)
66// NS_ENUM
67#[repr(transparent)]
68#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
69pub struct UITouchType(pub NSInteger);
70impl UITouchType {
71    #[doc(alias = "UITouchTypeDirect")]
72    pub const Direct: Self = Self(0);
73    #[doc(alias = "UITouchTypeIndirect")]
74    pub const Indirect: Self = Self(1);
75    #[doc(alias = "UITouchTypePencil")]
76    pub const Pencil: Self = Self(2);
77    #[doc(alias = "UITouchTypeStylus")]
78    pub const Stylus: Self = Self(UITouchType::Pencil.0);
79    #[doc(alias = "UITouchTypeIndirectPointer")]
80    pub const IndirectPointer: Self = Self(3);
81}
82
83unsafe impl Encode for UITouchType {
84    const ENCODING: Encoding = NSInteger::ENCODING;
85}
86
87unsafe impl RefEncode for UITouchType {
88    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
89}
90
91/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitouchproperties?language=objc)
92// NS_OPTIONS
93#[repr(transparent)]
94#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
95pub struct UITouchProperties(pub NSInteger);
96bitflags::bitflags! {
97    impl UITouchProperties: NSInteger {
98        #[doc(alias = "UITouchPropertyForce")]
99        const Force = 1<<0;
100        #[doc(alias = "UITouchPropertyAzimuth")]
101        const Azimuth = 1<<1;
102        #[doc(alias = "UITouchPropertyAltitude")]
103        const Altitude = 1<<2;
104        #[doc(alias = "UITouchPropertyLocation")]
105        const Location = 1<<3;
106        #[doc(alias = "UITouchPropertyRoll")]
107        const Roll = 1<<4;
108    }
109}
110
111unsafe impl Encode for UITouchProperties {
112    const ENCODING: Encoding = NSInteger::ENCODING;
113}
114
115unsafe impl RefEncode for UITouchProperties {
116    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
117}
118
119extern_class!(
120    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitouch?language=objc)
121    #[unsafe(super(NSObject))]
122    #[thread_kind = MainThreadOnly]
123    #[derive(Debug, PartialEq, Eq, Hash)]
124    pub struct UITouch;
125);
126
127unsafe impl NSObjectProtocol for UITouch {}
128
129impl UITouch {
130    extern_methods!(
131        #[unsafe(method(timestamp))]
132        #[unsafe(method_family = none)]
133        pub fn timestamp(&self) -> NSTimeInterval;
134
135        #[unsafe(method(phase))]
136        #[unsafe(method_family = none)]
137        pub fn phase(&self) -> UITouchPhase;
138
139        #[unsafe(method(tapCount))]
140        #[unsafe(method_family = none)]
141        pub fn tapCount(&self) -> NSUInteger;
142
143        #[unsafe(method(type))]
144        #[unsafe(method_family = none)]
145        pub fn r#type(&self) -> UITouchType;
146
147        #[cfg(feature = "objc2-core-foundation")]
148        #[unsafe(method(majorRadius))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn majorRadius(&self) -> CGFloat;
151
152        #[cfg(feature = "objc2-core-foundation")]
153        #[unsafe(method(majorRadiusTolerance))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn majorRadiusTolerance(&self) -> CGFloat;
156
157        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "UIWindow"))]
158        #[unsafe(method(window))]
159        #[unsafe(method_family = none)]
160        pub fn window(&self) -> Option<Retained<UIWindow>>;
161
162        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
163        #[unsafe(method(view))]
164        #[unsafe(method_family = none)]
165        pub fn view(&self) -> Option<Retained<UIView>>;
166
167        #[cfg(feature = "UIGestureRecognizer")]
168        #[unsafe(method(gestureRecognizers))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn gestureRecognizers(&self) -> Option<Retained<NSArray<UIGestureRecognizer>>>;
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 fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
180
181        #[cfg(all(
182            feature = "UIResponder",
183            feature = "UIView",
184            feature = "objc2-core-foundation"
185        ))]
186        #[unsafe(method(previousLocationInView:))]
187        #[unsafe(method_family = none)]
188        pub fn previousLocationInView(&self, view: Option<&UIView>) -> CGPoint;
189
190        #[cfg(all(
191            feature = "UIResponder",
192            feature = "UIView",
193            feature = "objc2-core-foundation"
194        ))]
195        #[unsafe(method(preciseLocationInView:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn preciseLocationInView(&self, view: Option<&UIView>) -> CGPoint;
198
199        #[cfg(all(
200            feature = "UIResponder",
201            feature = "UIView",
202            feature = "objc2-core-foundation"
203        ))]
204        #[unsafe(method(precisePreviousLocationInView:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn precisePreviousLocationInView(&self, view: Option<&UIView>) -> CGPoint;
207
208        #[cfg(feature = "objc2-core-foundation")]
209        #[unsafe(method(force))]
210        #[unsafe(method_family = none)]
211        pub fn force(&self) -> CGFloat;
212
213        #[cfg(feature = "objc2-core-foundation")]
214        #[unsafe(method(maximumPossibleForce))]
215        #[unsafe(method_family = none)]
216        pub fn maximumPossibleForce(&self) -> CGFloat;
217
218        #[cfg(all(
219            feature = "UIResponder",
220            feature = "UIView",
221            feature = "objc2-core-foundation"
222        ))]
223        #[unsafe(method(azimuthAngleInView:))]
224        #[unsafe(method_family = none)]
225        pub fn azimuthAngleInView(&self, view: Option<&UIView>) -> CGFloat;
226
227        #[cfg(all(
228            feature = "UIResponder",
229            feature = "UIView",
230            feature = "objc2-core-foundation"
231        ))]
232        #[unsafe(method(azimuthUnitVectorInView:))]
233        #[unsafe(method_family = none)]
234        pub fn azimuthUnitVectorInView(&self, view: Option<&UIView>) -> CGVector;
235
236        #[cfg(feature = "objc2-core-foundation")]
237        #[unsafe(method(altitudeAngle))]
238        #[unsafe(method_family = none)]
239        pub fn altitudeAngle(&self) -> CGFloat;
240
241        #[unsafe(method(estimationUpdateIndex))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn estimationUpdateIndex(&self) -> Option<Retained<NSNumber>>;
244
245        #[unsafe(method(estimatedProperties))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn estimatedProperties(&self) -> UITouchProperties;
248
249        #[unsafe(method(estimatedPropertiesExpectingUpdates))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn estimatedPropertiesExpectingUpdates(&self) -> UITouchProperties;
252
253        #[cfg(feature = "objc2-core-foundation")]
254        #[unsafe(method(rollAngle))]
255        #[unsafe(method_family = none)]
256        pub fn rollAngle(&self) -> CGFloat;
257    );
258}
259
260/// Methods declared on superclass `NSObject`.
261impl UITouch {
262    extern_methods!(
263        #[unsafe(method(init))]
264        #[unsafe(method_family = init)]
265        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
266
267        #[unsafe(method(new))]
268        #[unsafe(method_family = new)]
269        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
270    );
271}