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