objc2_ui_kit/generated/
UIMotionEffect.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
10extern_class!(
11    /// UIMotionEffect is an abstract superclass which declaratively represents a rendering
12    /// effect that depends on the motion of the device. Given some device pose, subclassers
13    /// provide relative values which are to be applied to the key paths of the target's view.
14    ///
15    /// Subclasses must implement conformance for NSCopying and NSCoding.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimotioneffect?language=objc)
18    #[unsafe(super(NSObject))]
19    #[thread_kind = MainThreadOnly]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct UIMotionEffect;
22);
23
24extern_conformance!(
25    unsafe impl NSCoding for UIMotionEffect {}
26);
27
28extern_conformance!(
29    unsafe impl NSCopying for UIMotionEffect {}
30);
31
32unsafe impl CopyingHelper for UIMotionEffect {
33    type Result = Self;
34}
35
36extern_conformance!(
37    unsafe impl NSObjectProtocol for UIMotionEffect {}
38);
39
40impl UIMotionEffect {
41    extern_methods!(
42        #[unsafe(method(init))]
43        #[unsafe(method_family = init)]
44        pub fn init(this: Allocated<Self>) -> Retained<Self>;
45
46        /// # Safety
47        ///
48        /// `coder` possibly has further requirements.
49        #[unsafe(method(initWithCoder:))]
50        #[unsafe(method_family = init)]
51        pub unsafe fn initWithCoder(
52            this: Allocated<Self>,
53            coder: &NSCoder,
54        ) -> Option<Retained<Self>>;
55
56        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
57        /// Abstract method. Given the `viewerOffset`, this method should compute a set of key paths
58        /// and relative values pairs which will represent the effect of the device's motion on
59        /// the target view. The return value is a dictionary whose keys and values are these
60        /// key paths (as NSStrings) and relative values, respectively.
61        ///
62        /// The `viewerOffset` is an estimate of the viewer's position relative to direction the
63        /// screen's facing. Values in each dimension range from -1 to 1. Facing straight at the
64        /// viewer is (0, 0). Tilting the phone to the right produces a more positive horizontal
65        /// value; tilting the phone down produces a more positive vertical value.
66        ///
67        /// `keyPaths` should be expressed relative to the effect's target view. Only key paths
68        /// which would animate if set in an animation block may be targeted by motion effects.
69        ///
70        /// Example return value: `
71        /// @
72        /// {
73        /// "
74        /// center": [NSValue
75        /// valueFromCGPoint:CGPointMake(3.4, 1.2)],
76        /// "
77        /// layer.shadowOffset.x":
78        /// @
79        /// (-1.1) }`
80        #[unsafe(method(keyPathsAndRelativeValuesForViewerOffset:))]
81        #[unsafe(method_family = none)]
82        pub fn keyPathsAndRelativeValuesForViewerOffset(
83            &self,
84            viewer_offset: UIOffset,
85        ) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
86    );
87}
88
89/// Methods declared on superclass `NSObject`.
90impl UIMotionEffect {
91    extern_methods!(
92        #[unsafe(method(new))]
93        #[unsafe(method_family = new)]
94        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
95    );
96}
97
98/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiinterpolatingmotioneffecttype?language=objc)
99// NS_ENUM
100#[repr(transparent)]
101#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
102pub struct UIInterpolatingMotionEffectType(pub NSInteger);
103impl UIInterpolatingMotionEffectType {
104    /// Tracks the device being tilted left/right relative to the viewer. The minimum
105    /// relative values maps to the device being tilted all the way to the left, the
106    /// maximum to the right.
107    #[doc(alias = "UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis")]
108    pub const TiltAlongHorizontalAxis: Self = Self(0);
109    /// Tracks the device being tilted up/down relative to the viewer. The minimum
110    /// relative values maps to the device being tilted all the way down, the maximum
111    /// all the way up.
112    #[doc(alias = "UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis")]
113    pub const TiltAlongVerticalAxis: Self = Self(1);
114}
115
116unsafe impl Encode for UIInterpolatingMotionEffectType {
117    const ENCODING: Encoding = NSInteger::ENCODING;
118}
119
120unsafe impl RefEncode for UIInterpolatingMotionEffectType {
121    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
122}
123
124extern_class!(
125    /// This motion effect maps movement of a particular type (e.g. left/right tilt) to an
126    /// interpolated output between two relative values provided by the client. Uses Core
127    /// Animation's implementation of interpolation for all the standard types.
128    ///
129    /// `keyPath` should be expressed relative to the effect's target view.
130    ///
131    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiinterpolatingmotioneffect?language=objc)
132    #[unsafe(super(UIMotionEffect, NSObject))]
133    #[thread_kind = MainThreadOnly]
134    #[derive(Debug, PartialEq, Eq, Hash)]
135    pub struct UIInterpolatingMotionEffect;
136);
137
138extern_conformance!(
139    unsafe impl NSCoding for UIInterpolatingMotionEffect {}
140);
141
142extern_conformance!(
143    unsafe impl NSCopying for UIInterpolatingMotionEffect {}
144);
145
146unsafe impl CopyingHelper for UIInterpolatingMotionEffect {
147    type Result = Self;
148}
149
150extern_conformance!(
151    unsafe impl NSObjectProtocol for UIInterpolatingMotionEffect {}
152);
153
154impl UIInterpolatingMotionEffect {
155    extern_methods!(
156        #[unsafe(method(initWithKeyPath:type:))]
157        #[unsafe(method_family = init)]
158        pub fn initWithKeyPath_type(
159            this: Allocated<Self>,
160            key_path: &NSString,
161            r#type: UIInterpolatingMotionEffectType,
162        ) -> Retained<Self>;
163
164        /// # Safety
165        ///
166        /// `coder` possibly has further requirements.
167        #[unsafe(method(initWithCoder:))]
168        #[unsafe(method_family = init)]
169        pub unsafe fn initWithCoder(
170            this: Allocated<Self>,
171            coder: &NSCoder,
172        ) -> Option<Retained<Self>>;
173
174        #[unsafe(method(keyPath))]
175        #[unsafe(method_family = none)]
176        pub fn keyPath(&self) -> Retained<NSString>;
177
178        #[unsafe(method(type))]
179        #[unsafe(method_family = none)]
180        pub fn r#type(&self) -> UIInterpolatingMotionEffectType;
181
182        #[unsafe(method(minimumRelativeValue))]
183        #[unsafe(method_family = none)]
184        pub fn minimumRelativeValue(&self) -> Option<Retained<AnyObject>>;
185
186        /// Setter for [`minimumRelativeValue`][Self::minimumRelativeValue].
187        ///
188        /// # Safety
189        ///
190        /// `minimum_relative_value` should be of the correct type.
191        #[unsafe(method(setMinimumRelativeValue:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn setMinimumRelativeValue(&self, minimum_relative_value: Option<&AnyObject>);
194
195        #[unsafe(method(maximumRelativeValue))]
196        #[unsafe(method_family = none)]
197        pub fn maximumRelativeValue(&self) -> Option<Retained<AnyObject>>;
198
199        /// Setter for [`maximumRelativeValue`][Self::maximumRelativeValue].
200        ///
201        /// # Safety
202        ///
203        /// `maximum_relative_value` should be of the correct type.
204        #[unsafe(method(setMaximumRelativeValue:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setMaximumRelativeValue(&self, maximum_relative_value: Option<&AnyObject>);
207    );
208}
209
210/// Methods declared on superclass `UIMotionEffect`.
211impl UIInterpolatingMotionEffect {
212    extern_methods!(
213        #[unsafe(method(init))]
214        #[unsafe(method_family = init)]
215        pub fn init(this: Allocated<Self>) -> Retained<Self>;
216    );
217}
218
219/// Methods declared on superclass `NSObject`.
220impl UIInterpolatingMotionEffect {
221    extern_methods!(
222        #[unsafe(method(new))]
223        #[unsafe(method_family = new)]
224        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
225    );
226}
227
228extern_class!(
229    /// Behaves like CAAnimationGroup. Merges key/value pairs of constituent
230    /// using Core Animation's implementations of addition for all the standard types.
231    ///
232    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimotioneffectgroup?language=objc)
233    #[unsafe(super(UIMotionEffect, NSObject))]
234    #[thread_kind = MainThreadOnly]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct UIMotionEffectGroup;
237);
238
239extern_conformance!(
240    unsafe impl NSCoding for UIMotionEffectGroup {}
241);
242
243extern_conformance!(
244    unsafe impl NSCopying for UIMotionEffectGroup {}
245);
246
247unsafe impl CopyingHelper for UIMotionEffectGroup {
248    type Result = Self;
249}
250
251extern_conformance!(
252    unsafe impl NSObjectProtocol for UIMotionEffectGroup {}
253);
254
255impl UIMotionEffectGroup {
256    extern_methods!(
257        #[unsafe(method(motionEffects))]
258        #[unsafe(method_family = none)]
259        pub fn motionEffects(&self) -> Option<Retained<NSArray<UIMotionEffect>>>;
260
261        /// Setter for [`motionEffects`][Self::motionEffects].
262        ///
263        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
264        #[unsafe(method(setMotionEffects:))]
265        #[unsafe(method_family = none)]
266        pub fn setMotionEffects(&self, motion_effects: Option<&NSArray<UIMotionEffect>>);
267    );
268}
269
270/// Methods declared on superclass `UIMotionEffect`.
271impl UIMotionEffectGroup {
272    extern_methods!(
273        #[unsafe(method(init))]
274        #[unsafe(method_family = init)]
275        pub fn init(this: Allocated<Self>) -> Retained<Self>;
276
277        /// # Safety
278        ///
279        /// `coder` possibly has further requirements.
280        #[unsafe(method(initWithCoder:))]
281        #[unsafe(method_family = init)]
282        pub unsafe fn initWithCoder(
283            this: Allocated<Self>,
284            coder: &NSCoder,
285        ) -> Option<Retained<Self>>;
286    );
287}
288
289/// Methods declared on superclass `NSObject`.
290impl UIMotionEffectGroup {
291    extern_methods!(
292        #[unsafe(method(new))]
293        #[unsafe(method_family = new)]
294        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
295    );
296}