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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// UIMotionEffect is an abstract superclass which declaratively represents a rendering
/// effect that depends on the motion of the device. Given some device pose, subclassers
/// provide relative values which are to be applied to the key paths of the target's view.
///
/// Subclasses must implement conformance for NSCopying and NSCoding.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimotioneffect?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIMotionEffect;
);
extern_conformance!(
unsafe impl NSCoding for UIMotionEffect {}
);
extern_conformance!(
unsafe impl NSCopying for UIMotionEffect {}
);
unsafe impl CopyingHelper for UIMotionEffect {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UIMotionEffect {}
);
impl UIMotionEffect {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
/// Abstract method. Given the `viewerOffset`, this method should compute a set of key paths
/// and relative values pairs which will represent the effect of the device's motion on
/// the target view. The return value is a dictionary whose keys and values are these
/// key paths (as NSStrings) and relative values, respectively.
///
/// The `viewerOffset` is an estimate of the viewer's position relative to direction the
/// screen's facing. Values in each dimension range from -1 to 1. Facing straight at the
/// viewer is (0, 0). Tilting the phone to the right produces a more positive horizontal
/// value; tilting the phone down produces a more positive vertical value.
///
/// `keyPaths` should be expressed relative to the effect's target view. Only key paths
/// which would animate if set in an animation block may be targeted by motion effects.
///
/// Example return value: `
/// @
/// {
/// "
/// center": [NSValue
/// valueFromCGPoint:CGPointMake(3.4, 1.2)],
/// "
/// layer.shadowOffset.x":
/// @
/// (-1.1) }`
#[unsafe(method(keyPathsAndRelativeValuesForViewerOffset:))]
#[unsafe(method_family = none)]
pub fn keyPathsAndRelativeValuesForViewerOffset(
&self,
viewer_offset: UIOffset,
) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
);
}
/// Methods declared on superclass `NSObject`.
impl UIMotionEffect {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiinterpolatingmotioneffecttype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIInterpolatingMotionEffectType(pub NSInteger);
impl UIInterpolatingMotionEffectType {
/// Tracks the device being tilted left/right relative to the viewer. The minimum
/// relative values maps to the device being tilted all the way to the left, the
/// maximum to the right.
#[doc(alias = "UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis")]
pub const TiltAlongHorizontalAxis: Self = Self(0);
/// Tracks the device being tilted up/down relative to the viewer. The minimum
/// relative values maps to the device being tilted all the way down, the maximum
/// all the way up.
#[doc(alias = "UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis")]
pub const TiltAlongVerticalAxis: Self = Self(1);
}
unsafe impl Encode for UIInterpolatingMotionEffectType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIInterpolatingMotionEffectType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// This motion effect maps movement of a particular type (e.g. left/right tilt) to an
/// interpolated output between two relative values provided by the client. Uses Core
/// Animation's implementation of interpolation for all the standard types.
///
/// `keyPath` should be expressed relative to the effect's target view.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiinterpolatingmotioneffect?language=objc)
#[unsafe(super(UIMotionEffect, NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIInterpolatingMotionEffect;
);
extern_conformance!(
unsafe impl NSCoding for UIInterpolatingMotionEffect {}
);
extern_conformance!(
unsafe impl NSCopying for UIInterpolatingMotionEffect {}
);
unsafe impl CopyingHelper for UIInterpolatingMotionEffect {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UIInterpolatingMotionEffect {}
);
impl UIInterpolatingMotionEffect {
extern_methods!(
#[unsafe(method(initWithKeyPath:type:))]
#[unsafe(method_family = init)]
pub fn initWithKeyPath_type(
this: Allocated<Self>,
key_path: &NSString,
r#type: UIInterpolatingMotionEffectType,
) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[unsafe(method(keyPath))]
#[unsafe(method_family = none)]
pub fn keyPath(&self) -> Retained<NSString>;
#[unsafe(method(type))]
#[unsafe(method_family = none)]
pub fn r#type(&self) -> UIInterpolatingMotionEffectType;
#[unsafe(method(minimumRelativeValue))]
#[unsafe(method_family = none)]
pub fn minimumRelativeValue(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`minimumRelativeValue`][Self::minimumRelativeValue].
///
/// # Safety
///
/// `minimum_relative_value` should be of the correct type.
#[unsafe(method(setMinimumRelativeValue:))]
#[unsafe(method_family = none)]
pub unsafe fn setMinimumRelativeValue(&self, minimum_relative_value: Option<&AnyObject>);
#[unsafe(method(maximumRelativeValue))]
#[unsafe(method_family = none)]
pub fn maximumRelativeValue(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`maximumRelativeValue`][Self::maximumRelativeValue].
///
/// # Safety
///
/// `maximum_relative_value` should be of the correct type.
#[unsafe(method(setMaximumRelativeValue:))]
#[unsafe(method_family = none)]
pub unsafe fn setMaximumRelativeValue(&self, maximum_relative_value: Option<&AnyObject>);
);
}
/// Methods declared on superclass `UIMotionEffect`.
impl UIInterpolatingMotionEffect {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl UIInterpolatingMotionEffect {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
extern_class!(
/// Behaves like CAAnimationGroup. Merges key/value pairs of constituent
/// using Core Animation's implementations of addition for all the standard types.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimotioneffectgroup?language=objc)
#[unsafe(super(UIMotionEffect, NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIMotionEffectGroup;
);
extern_conformance!(
unsafe impl NSCoding for UIMotionEffectGroup {}
);
extern_conformance!(
unsafe impl NSCopying for UIMotionEffectGroup {}
);
unsafe impl CopyingHelper for UIMotionEffectGroup {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UIMotionEffectGroup {}
);
impl UIMotionEffectGroup {
extern_methods!(
#[unsafe(method(motionEffects))]
#[unsafe(method_family = none)]
pub fn motionEffects(&self) -> Option<Retained<NSArray<UIMotionEffect>>>;
/// Setter for [`motionEffects`][Self::motionEffects].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setMotionEffects:))]
#[unsafe(method_family = none)]
pub fn setMotionEffects(&self, motion_effects: Option<&NSArray<UIMotionEffect>>);
);
}
/// Methods declared on superclass `UIMotionEffect`.
impl UIMotionEffectGroup {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
);
}
/// Methods declared on superclass `NSObject`.
impl UIMotionEffectGroup {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}