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