objc2_scene_kit/generated/
SCNAction.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// A custom timing function for SCNActions. Input time will be between 0.0 and 1.0
13/// over the duration of the action. Return values must be 0.0-1.0 and increasing
14/// and the function must return 1.0 when the input time reaches 1.0.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnactiontimingfunction?language=objc)
17#[cfg(feature = "block2")]
18pub type SCNActionTimingFunction = *mut block2::Block<dyn Fn(c_float) -> c_float>;
19
20extern_protocol!(
21    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnactionable?language=objc)
22    pub unsafe trait SCNActionable: NSObjectProtocol {
23        /// Adds an action to the list of actions executed by the node.
24        #[unsafe(method(runAction:))]
25        #[unsafe(method_family = none)]
26        unsafe fn runAction(&self, action: &SCNAction);
27
28        #[cfg(feature = "block2")]
29        /// Adds an action to the list of actions executed by the node. Your block is called when the action completes.
30        #[unsafe(method(runAction:completionHandler:))]
31        #[unsafe(method_family = none)]
32        unsafe fn runAction_completionHandler(
33            &self,
34            action: &SCNAction,
35            block: Option<&block2::Block<dyn Fn()>>,
36        );
37
38        /// Adds an identifiable action to the list of actions executed by the node.
39        #[unsafe(method(runAction:forKey:))]
40        #[unsafe(method_family = none)]
41        unsafe fn runAction_forKey(&self, action: &SCNAction, key: Option<&NSString>);
42
43        #[cfg(feature = "block2")]
44        /// Adds an identifiable action to the list of actions executed by the node. Your block is called when the action completes.
45        #[unsafe(method(runAction:forKey:completionHandler:))]
46        #[unsafe(method_family = none)]
47        unsafe fn runAction_forKey_completionHandler(
48            &self,
49            action: &SCNAction,
50            key: Option<&NSString>,
51            block: Option<&block2::Block<dyn Fn()>>,
52        );
53
54        /// Returns a Boolean value that indicates whether the node is executing actions.
55        #[unsafe(method(hasActions))]
56        #[unsafe(method_family = none)]
57        unsafe fn hasActions(&self) -> bool;
58
59        /// Returns an action associated with a specific key.
60        #[unsafe(method(actionForKey:))]
61        #[unsafe(method_family = none)]
62        unsafe fn actionForKey(&self, key: &NSString) -> Option<Retained<SCNAction>>;
63
64        /// Removes an action associated with a specific key.
65        #[unsafe(method(removeActionForKey:))]
66        #[unsafe(method_family = none)]
67        unsafe fn removeActionForKey(&self, key: &NSString);
68
69        /// Ends and removes all actions from the node.
70        #[unsafe(method(removeAllActions))]
71        #[unsafe(method_family = none)]
72        unsafe fn removeAllActions(&self);
73
74        /// Returns an array containing the keys of all actions currently attached to the receiver.
75        #[unsafe(method(actionKeys))]
76        #[unsafe(method_family = none)]
77        unsafe fn actionKeys(&self) -> Retained<NSArray<NSString>>;
78    }
79);
80
81extern_class!(
82    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnaction?language=objc)
83    #[unsafe(super(NSObject))]
84    #[derive(Debug, PartialEq, Eq, Hash)]
85    pub struct SCNAction;
86);
87
88unsafe impl NSCoding for SCNAction {}
89
90unsafe impl NSCopying for SCNAction {}
91
92unsafe impl CopyingHelper for SCNAction {
93    type Result = Self;
94}
95
96unsafe impl NSObjectProtocol for SCNAction {}
97
98unsafe impl NSSecureCoding for SCNAction {}
99
100impl SCNAction {
101    extern_methods!(
102        /// This is the expected duration of an action’s animation. The actual time an action takes to complete is modified by the speed property of the action.
103        #[unsafe(method(duration))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn duration(&self) -> NSTimeInterval;
106
107        /// Setter for [`duration`][Self::duration].
108        #[unsafe(method(setDuration:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setDuration(&self, duration: NSTimeInterval);
111
112        #[cfg(feature = "SceneKitTypes")]
113        /// The timing mode used to execute an action.
114        #[unsafe(method(timingMode))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn timingMode(&self) -> SCNActionTimingMode;
117
118        #[cfg(feature = "SceneKitTypes")]
119        /// Setter for [`timingMode`][Self::timingMode].
120        #[unsafe(method(setTimingMode:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setTimingMode(&self, timing_mode: SCNActionTimingMode);
123
124        #[cfg(feature = "block2")]
125        /// When set, prodives a custom timing via a block. Applies after
126        /// the 'timingMode' property is taken into account, defaults to nil
127        ///
128        /// See: SCNActionTimingFunction
129        #[unsafe(method(timingFunction))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn timingFunction(&self) -> SCNActionTimingFunction;
132
133        #[cfg(feature = "block2")]
134        /// Setter for [`timingFunction`][Self::timingFunction].
135        #[unsafe(method(setTimingFunction:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setTimingFunction(&self, timing_function: SCNActionTimingFunction);
138
139        #[cfg(feature = "objc2-core-foundation")]
140        /// A speed factor that modifies how fast an action runs. Defaults to 1.
141        #[unsafe(method(speed))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn speed(&self) -> CGFloat;
144
145        #[cfg(feature = "objc2-core-foundation")]
146        /// Setter for [`speed`][Self::speed].
147        #[unsafe(method(setSpeed:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn setSpeed(&self, speed: CGFloat);
150
151        /// Creates an action that reverses the behavior of another action.
152        #[unsafe(method(reversedAction))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn reversedAction(&self) -> Retained<SCNAction>;
155
156        #[cfg(feature = "objc2-core-foundation")]
157        #[unsafe(method(moveByX:y:z:duration:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn moveByX_y_z_duration(
160            delta_x: CGFloat,
161            delta_y: CGFloat,
162            delta_z: CGFloat,
163            duration: NSTimeInterval,
164        ) -> Retained<SCNAction>;
165
166        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
167        #[unsafe(method(moveBy:duration:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn moveBy_duration(
170            delta: SCNVector3,
171            duration: NSTimeInterval,
172        ) -> Retained<SCNAction>;
173
174        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
175        #[unsafe(method(moveTo:duration:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn moveTo_duration(
178            location: SCNVector3,
179            duration: NSTimeInterval,
180        ) -> Retained<SCNAction>;
181
182        #[cfg(feature = "objc2-core-foundation")]
183        #[unsafe(method(rotateByX:y:z:duration:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn rotateByX_y_z_duration(
186            x_angle: CGFloat,
187            y_angle: CGFloat,
188            z_angle: CGFloat,
189            duration: NSTimeInterval,
190        ) -> Retained<SCNAction>;
191
192        #[cfg(feature = "objc2-core-foundation")]
193        #[unsafe(method(rotateToX:y:z:duration:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn rotateToX_y_z_duration(
196            x_angle: CGFloat,
197            y_angle: CGFloat,
198            z_angle: CGFloat,
199            duration: NSTimeInterval,
200        ) -> Retained<SCNAction>;
201
202        #[cfg(feature = "objc2-core-foundation")]
203        #[unsafe(method(rotateToX:y:z:duration:shortestUnitArc:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn rotateToX_y_z_duration_shortestUnitArc(
206            x_angle: CGFloat,
207            y_angle: CGFloat,
208            z_angle: CGFloat,
209            duration: NSTimeInterval,
210            shortest_unit_arc: bool,
211        ) -> Retained<SCNAction>;
212
213        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
214        #[unsafe(method(rotateByAngle:aroundAxis:duration:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn rotateByAngle_aroundAxis_duration(
217            angle: CGFloat,
218            axis: SCNVector3,
219            duration: NSTimeInterval,
220        ) -> Retained<SCNAction>;
221
222        #[cfg(all(feature = "SceneKitTypes", feature = "objc2-core-foundation"))]
223        #[unsafe(method(rotateToAxisAngle:duration:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn rotateToAxisAngle_duration(
226            axis_angle: SCNVector4,
227            duration: NSTimeInterval,
228        ) -> Retained<SCNAction>;
229
230        #[cfg(feature = "objc2-core-foundation")]
231        #[unsafe(method(scaleBy:duration:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn scaleBy_duration(scale: CGFloat, sec: NSTimeInterval) -> Retained<SCNAction>;
234
235        #[cfg(feature = "objc2-core-foundation")]
236        #[unsafe(method(scaleTo:duration:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn scaleTo_duration(scale: CGFloat, sec: NSTimeInterval) -> Retained<SCNAction>;
239
240        #[unsafe(method(sequence:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn sequence(actions: &NSArray<SCNAction>) -> Retained<SCNAction>;
243
244        #[unsafe(method(group:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn group(actions: &NSArray<SCNAction>) -> Retained<SCNAction>;
247
248        #[unsafe(method(repeatAction:count:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn repeatAction_count(
251            action: &SCNAction,
252            count: NSUInteger,
253        ) -> Retained<SCNAction>;
254
255        #[unsafe(method(repeatActionForever:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn repeatActionForever(action: &SCNAction) -> Retained<SCNAction>;
258
259        #[unsafe(method(fadeInWithDuration:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn fadeInWithDuration(sec: NSTimeInterval) -> Retained<SCNAction>;
262
263        #[unsafe(method(fadeOutWithDuration:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn fadeOutWithDuration(sec: NSTimeInterval) -> Retained<SCNAction>;
266
267        #[cfg(feature = "objc2-core-foundation")]
268        #[unsafe(method(fadeOpacityBy:duration:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn fadeOpacityBy_duration(
271            factor: CGFloat,
272            sec: NSTimeInterval,
273        ) -> Retained<SCNAction>;
274
275        #[cfg(feature = "objc2-core-foundation")]
276        #[unsafe(method(fadeOpacityTo:duration:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn fadeOpacityTo_duration(
279            opacity: CGFloat,
280            sec: NSTimeInterval,
281        ) -> Retained<SCNAction>;
282
283        #[unsafe(method(hide))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn hide() -> Retained<SCNAction>;
286
287        #[unsafe(method(unhide))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn unhide() -> Retained<SCNAction>;
290
291        #[unsafe(method(waitForDuration:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn waitForDuration(sec: NSTimeInterval) -> Retained<SCNAction>;
294
295        #[unsafe(method(waitForDuration:withRange:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn waitForDuration_withRange(
298            sec: NSTimeInterval,
299            duration_range: NSTimeInterval,
300        ) -> Retained<SCNAction>;
301
302        #[unsafe(method(removeFromParentNode))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn removeFromParentNode() -> Retained<SCNAction>;
305
306        #[cfg(all(feature = "SCNNode", feature = "block2"))]
307        #[unsafe(method(runBlock:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn runBlock(
310            block: &block2::Block<dyn Fn(NonNull<SCNNode>)>,
311        ) -> Retained<SCNAction>;
312
313        #[unsafe(method(javaScriptActionWithScript:duration:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn javaScriptActionWithScript_duration(
316            script: &NSString,
317            seconds: NSTimeInterval,
318        ) -> Retained<SCNAction>;
319
320        #[cfg(all(
321            feature = "SCNNode",
322            feature = "block2",
323            feature = "objc2-core-foundation"
324        ))]
325        #[unsafe(method(customActionWithDuration:actionBlock:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn customActionWithDuration_actionBlock(
328            seconds: NSTimeInterval,
329            block: &block2::Block<dyn Fn(NonNull<SCNNode>, CGFloat)>,
330        ) -> Retained<SCNAction>;
331
332        #[cfg(feature = "SCNAudioSource")]
333        /// Creates an action that plays a sound
334        ///
335        /// Parameter `source`: The audio source to play (see SCNAudioSource.h)
336        ///
337        /// Parameter `wait`: If YES, then the duration of this action is the same
338        /// as the length of the audio playback. If NO, the action is considered
339        /// to have completed immediately.
340        #[unsafe(method(playAudioSource:waitForCompletion:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn playAudioSource_waitForCompletion(
343            source: &SCNAudioSource,
344            wait: bool,
345        ) -> Retained<SCNAction>;
346    );
347}
348
349/// Methods declared on superclass `NSObject`.
350impl SCNAction {
351    extern_methods!(
352        #[unsafe(method(init))]
353        #[unsafe(method_family = init)]
354        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
355
356        #[unsafe(method(new))]
357        #[unsafe(method_family = new)]
358        pub unsafe fn new() -> Retained<Self>;
359    );
360}