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