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