objc2_ui_kit/generated/
UITouch.rs1use 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#[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#[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#[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#[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 #[unsafe(super(NSObject))]
122 #[thread_kind = MainThreadOnly]
123 #[derive(Debug, PartialEq, Eq, Hash)]
124 pub struct UITouch;
125);
126
127extern_conformance!(
128 unsafe impl NSObjectProtocol for UITouch {}
129);
130
131impl UITouch {
132 extern_methods!(
133 #[unsafe(method(timestamp))]
134 #[unsafe(method_family = none)]
135 pub fn timestamp(&self) -> NSTimeInterval;
136
137 #[unsafe(method(phase))]
138 #[unsafe(method_family = none)]
139 pub fn phase(&self) -> UITouchPhase;
140
141 #[unsafe(method(tapCount))]
142 #[unsafe(method_family = none)]
143 pub fn tapCount(&self) -> NSUInteger;
144
145 #[unsafe(method(type))]
146 #[unsafe(method_family = none)]
147 pub fn r#type(&self) -> UITouchType;
148
149 #[cfg(feature = "objc2-core-foundation")]
150 #[unsafe(method(majorRadius))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn majorRadius(&self) -> CGFloat;
153
154 #[cfg(feature = "objc2-core-foundation")]
155 #[unsafe(method(majorRadiusTolerance))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn majorRadiusTolerance(&self) -> CGFloat;
158
159 #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "UIWindow"))]
160 #[unsafe(method(window))]
161 #[unsafe(method_family = none)]
162 pub fn window(&self) -> Option<Retained<UIWindow>>;
163
164 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
165 #[unsafe(method(view))]
166 #[unsafe(method_family = none)]
167 pub fn view(&self) -> Option<Retained<UIView>>;
168
169 #[cfg(feature = "UIGestureRecognizer")]
170 #[unsafe(method(gestureRecognizers))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn gestureRecognizers(&self) -> Option<Retained<NSArray<UIGestureRecognizer>>>;
173
174 #[cfg(all(
175 feature = "UIResponder",
176 feature = "UIView",
177 feature = "objc2-core-foundation"
178 ))]
179 #[unsafe(method(locationInView:))]
180 #[unsafe(method_family = none)]
181 pub fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
182
183 #[cfg(all(
184 feature = "UIResponder",
185 feature = "UIView",
186 feature = "objc2-core-foundation"
187 ))]
188 #[unsafe(method(previousLocationInView:))]
189 #[unsafe(method_family = none)]
190 pub fn previousLocationInView(&self, view: Option<&UIView>) -> CGPoint;
191
192 #[cfg(all(
193 feature = "UIResponder",
194 feature = "UIView",
195 feature = "objc2-core-foundation"
196 ))]
197 #[unsafe(method(preciseLocationInView:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn preciseLocationInView(&self, view: Option<&UIView>) -> CGPoint;
200
201 #[cfg(all(
202 feature = "UIResponder",
203 feature = "UIView",
204 feature = "objc2-core-foundation"
205 ))]
206 #[unsafe(method(precisePreviousLocationInView:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn precisePreviousLocationInView(&self, view: Option<&UIView>) -> CGPoint;
209
210 #[cfg(feature = "objc2-core-foundation")]
211 #[unsafe(method(force))]
212 #[unsafe(method_family = none)]
213 pub fn force(&self) -> CGFloat;
214
215 #[cfg(feature = "objc2-core-foundation")]
216 #[unsafe(method(maximumPossibleForce))]
217 #[unsafe(method_family = none)]
218 pub fn maximumPossibleForce(&self) -> CGFloat;
219
220 #[cfg(all(
221 feature = "UIResponder",
222 feature = "UIView",
223 feature = "objc2-core-foundation"
224 ))]
225 #[unsafe(method(azimuthAngleInView:))]
226 #[unsafe(method_family = none)]
227 pub fn azimuthAngleInView(&self, view: Option<&UIView>) -> CGFloat;
228
229 #[cfg(all(
230 feature = "UIResponder",
231 feature = "UIView",
232 feature = "objc2-core-foundation"
233 ))]
234 #[unsafe(method(azimuthUnitVectorInView:))]
235 #[unsafe(method_family = none)]
236 pub fn azimuthUnitVectorInView(&self, view: Option<&UIView>) -> CGVector;
237
238 #[cfg(feature = "objc2-core-foundation")]
239 #[unsafe(method(altitudeAngle))]
240 #[unsafe(method_family = none)]
241 pub fn altitudeAngle(&self) -> CGFloat;
242
243 #[unsafe(method(estimationUpdateIndex))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn estimationUpdateIndex(&self) -> Option<Retained<NSNumber>>;
246
247 #[unsafe(method(estimatedProperties))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn estimatedProperties(&self) -> UITouchProperties;
250
251 #[unsafe(method(estimatedPropertiesExpectingUpdates))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn estimatedPropertiesExpectingUpdates(&self) -> UITouchProperties;
254
255 #[cfg(feature = "objc2-core-foundation")]
256 #[unsafe(method(rollAngle))]
257 #[unsafe(method_family = none)]
258 pub fn rollAngle(&self) -> CGFloat;
259 );
260}
261
262impl UITouch {
264 extern_methods!(
265 #[unsafe(method(init))]
266 #[unsafe(method_family = init)]
267 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
268
269 #[unsafe(method(new))]
270 #[unsafe(method_family = new)]
271 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
272 );
273}