objc2_scene_kit/generated/
SCNView.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-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnviewoption?language=objc)
16// NS_TYPED_ENUM
17pub type SCNViewOption = NSString;
18
19extern "C" {
20    /// Pass it as the key in the options dictionary given to initWithFrame:options:. The value is a NSNumber wrapping a SCNRenderingAPI. You can also select the preferred rendering API directly from the SCNView inspector in InterfaceBuilder.
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnpreferredrenderingapikey?language=objc)
23    pub static SCNPreferredRenderingAPIKey: &'static SCNViewOption;
24}
25
26extern "C" {
27    /// The value is directly a id
28    /// <MTLDevice
29    /// >.
30    ///
31    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnpreferreddevicekey?language=objc)
32    pub static SCNPreferredDeviceKey: &'static SCNViewOption;
33}
34
35extern "C" {
36    /// The value is a NSNumber wrapping a BOOL. Defaults to NO.
37    ///
38    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnpreferlowpowerdevicekey?language=objc)
39    pub static SCNPreferLowPowerDeviceKey: &'static SCNViewOption;
40}
41
42extern_protocol!(
43    /// [Apple's documentation](https://developer.apple.com/documentation/scenekit/scncameracontrolconfiguration?language=objc)
44    pub unsafe trait SCNCameraControlConfiguration: NSObjectProtocol {
45        #[unsafe(method(autoSwitchToFreeCamera))]
46        #[unsafe(method_family = none)]
47        unsafe fn autoSwitchToFreeCamera(&self) -> bool;
48
49        /// Setter for [`autoSwitchToFreeCamera`][Self::autoSwitchToFreeCamera].
50        #[unsafe(method(setAutoSwitchToFreeCamera:))]
51        #[unsafe(method_family = none)]
52        unsafe fn setAutoSwitchToFreeCamera(&self, auto_switch_to_free_camera: bool);
53
54        #[unsafe(method(allowsTranslation))]
55        #[unsafe(method_family = none)]
56        unsafe fn allowsTranslation(&self) -> bool;
57
58        /// Setter for [`allowsTranslation`][Self::allowsTranslation].
59        #[unsafe(method(setAllowsTranslation:))]
60        #[unsafe(method_family = none)]
61        unsafe fn setAllowsTranslation(&self, allows_translation: bool);
62
63        #[cfg(feature = "objc2-core-foundation")]
64        #[unsafe(method(flyModeVelocity))]
65        #[unsafe(method_family = none)]
66        unsafe fn flyModeVelocity(&self) -> CGFloat;
67
68        #[cfg(feature = "objc2-core-foundation")]
69        /// Setter for [`flyModeVelocity`][Self::flyModeVelocity].
70        #[unsafe(method(setFlyModeVelocity:))]
71        #[unsafe(method_family = none)]
72        unsafe fn setFlyModeVelocity(&self, fly_mode_velocity: CGFloat);
73
74        #[cfg(feature = "objc2-core-foundation")]
75        #[unsafe(method(panSensitivity))]
76        #[unsafe(method_family = none)]
77        unsafe fn panSensitivity(&self) -> CGFloat;
78
79        #[cfg(feature = "objc2-core-foundation")]
80        /// Setter for [`panSensitivity`][Self::panSensitivity].
81        #[unsafe(method(setPanSensitivity:))]
82        #[unsafe(method_family = none)]
83        unsafe fn setPanSensitivity(&self, pan_sensitivity: CGFloat);
84
85        #[cfg(feature = "objc2-core-foundation")]
86        #[unsafe(method(truckSensitivity))]
87        #[unsafe(method_family = none)]
88        unsafe fn truckSensitivity(&self) -> CGFloat;
89
90        #[cfg(feature = "objc2-core-foundation")]
91        /// Setter for [`truckSensitivity`][Self::truckSensitivity].
92        #[unsafe(method(setTruckSensitivity:))]
93        #[unsafe(method_family = none)]
94        unsafe fn setTruckSensitivity(&self, truck_sensitivity: CGFloat);
95
96        #[cfg(feature = "objc2-core-foundation")]
97        #[unsafe(method(rotationSensitivity))]
98        #[unsafe(method_family = none)]
99        unsafe fn rotationSensitivity(&self) -> CGFloat;
100
101        #[cfg(feature = "objc2-core-foundation")]
102        /// Setter for [`rotationSensitivity`][Self::rotationSensitivity].
103        #[unsafe(method(setRotationSensitivity:))]
104        #[unsafe(method_family = none)]
105        unsafe fn setRotationSensitivity(&self, rotation_sensitivity: CGFloat);
106    }
107);
108
109extern_class!(
110    /// A SCNView is a subclass of NSView that can display a SCNScene
111    ///
112    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnview?language=objc)
113    #[unsafe(super(NSView, NSResponder, NSObject))]
114    #[derive(Debug, PartialEq, Eq, Hash)]
115    #[cfg(feature = "objc2-app-kit")]
116    #[cfg(target_os = "macos")]
117    pub struct SCNView;
118);
119
120#[cfg(feature = "objc2-app-kit")]
121#[cfg(target_os = "macos")]
122unsafe impl NSAccessibility for SCNView {}
123
124#[cfg(feature = "objc2-app-kit")]
125#[cfg(target_os = "macos")]
126unsafe impl NSAccessibilityElementProtocol for SCNView {}
127
128#[cfg(feature = "objc2-app-kit")]
129#[cfg(target_os = "macos")]
130unsafe impl NSAnimatablePropertyContainer for SCNView {}
131
132#[cfg(feature = "objc2-app-kit")]
133#[cfg(target_os = "macos")]
134unsafe impl NSAppearanceCustomization for SCNView {}
135
136#[cfg(feature = "objc2-app-kit")]
137#[cfg(target_os = "macos")]
138unsafe impl NSCoding for SCNView {}
139
140#[cfg(feature = "objc2-app-kit")]
141#[cfg(target_os = "macos")]
142unsafe impl NSDraggingDestination for SCNView {}
143
144#[cfg(feature = "objc2-app-kit")]
145#[cfg(target_os = "macos")]
146unsafe impl NSObjectProtocol for SCNView {}
147
148#[cfg(feature = "objc2-app-kit")]
149#[cfg(target_os = "macos")]
150unsafe impl NSUserInterfaceItemIdentification for SCNView {}
151
152#[cfg(all(feature = "SCNSceneRenderer", feature = "objc2-app-kit"))]
153#[cfg(target_os = "macos")]
154unsafe impl SCNSceneRenderer for SCNView {}
155
156#[cfg(all(feature = "SCNTechnique", feature = "objc2-app-kit"))]
157#[cfg(target_os = "macos")]
158unsafe impl SCNTechniqueSupport for SCNView {}
159
160#[cfg(feature = "objc2-app-kit")]
161#[cfg(target_os = "macos")]
162impl SCNView {
163    extern_methods!(
164        /// Initializes and returns a newly allocated SCNView object with a specified frame rectangle.
165        ///
166        /// Parameter `frame`: The frame rectangle for the created view object.
167        ///
168        /// Parameter `options`: An optional dictionary. See "View initialization options" above.
169        #[unsafe(method(initWithFrame:options:))]
170        #[unsafe(method_family = init)]
171        pub unsafe fn initWithFrame_options(
172            this: Allocated<Self>,
173            frame: NSRect,
174            options: Option<&NSDictionary<NSString, AnyObject>>,
175        ) -> Retained<Self>;
176
177        #[cfg(feature = "SCNScene")]
178        /// Specifies the scene of the receiver
179        #[unsafe(method(scene))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn scene(&self) -> Option<Retained<SCNScene>>;
182
183        #[cfg(feature = "SCNScene")]
184        /// Setter for [`scene`][Self::scene].
185        #[unsafe(method(setScene:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setScene(&self, scene: Option<&SCNScene>);
188
189        /// When set to YES, the view continously redraw at the display link frame rate. When set to NO the view will only redraw when something change or animates in the receiver's scene. Defaults to NO.
190        #[unsafe(method(rendersContinuously))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn rendersContinuously(&self) -> bool;
193
194        /// Setter for [`rendersContinuously`][Self::rendersContinuously].
195        #[unsafe(method(setRendersContinuously:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setRendersContinuously(&self, renders_continuously: bool);
198
199        /// Specifies the background color of the receiver. Defaults to opaque white.
200        #[unsafe(method(backgroundColor))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn backgroundColor(&self) -> Retained<NSColor>;
203
204        /// Setter for [`backgroundColor`][Self::backgroundColor].
205        #[unsafe(method(setBackgroundColor:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn setBackgroundColor(&self, background_color: &NSColor);
208
209        /// A Boolean value that determines whether the user can manipulate the point of view used to render the scene.
210        ///
211        /// When set to YES, the user can manipulate the current point of view with the mouse or the trackpad. The scene graph and existing cameras won't be modified by this action. The default value of this property is NO.
212        /// Note that the primary purpose of this property is to aid in debugging your application. You may want to implement your own camera controller suitable for your application.
213        /// The built-in camera controller let you:
214        /// - drag the mouse to rotate the camera around the scene
215        /// - drag+cmd to rotate the camera in local space
216        /// - drag+shift to rotate using sticky axis
217        /// - use the scroll wheel or alt+drag the mouse to translate the camera on its local X,Y plan
218        /// - alt+scroll wheel to move the camera forward/backward
219        /// - rotate gesture (trackpad only) to roll the camera (rotation around the Z axis)
220        /// - pinch gesture (trackpad only) move the camera forward/backward
221        /// - alt + pinch gesture (trackpad only) to zoom-in / zoom-out (change the field of view of the camera)
222        #[unsafe(method(allowsCameraControl))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn allowsCameraControl(&self) -> bool;
225
226        /// Setter for [`allowsCameraControl`][Self::allowsCameraControl].
227        #[unsafe(method(setAllowsCameraControl:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setAllowsCameraControl(&self, allows_camera_control: bool);
230
231        /// An object describing the current configuration of the event handler which pilot the default camera controller.
232        ///
233        /// This object will be used to configure the event handler when allowCameraControl is set to YES.
234        #[unsafe(method(cameraControlConfiguration))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn cameraControlConfiguration(
237            &self,
238        ) -> Retained<ProtocolObject<dyn SCNCameraControlConfiguration>>;
239
240        #[cfg(feature = "SCNCameraController")]
241        /// Returns the default SCNCameraController used to drive the current point of view when allowCameraController is set to YES.
242        #[unsafe(method(defaultCameraController))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn defaultCameraController(&self) -> Retained<SCNCameraController>;
245
246        /// Draws the contents of the view and returns them as a new image object
247        ///
248        /// This method is thread-safe and may be called at any time.
249        #[unsafe(method(snapshot))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn snapshot(&self) -> Retained<NSImage>;
252
253        /// This action method begins playing the scene at its current location.
254        ///
255        /// Parameter `sender`: The object (such as a button or menu item) sending the message to play the scene.
256        ///
257        /// This method does not do anything if the scene is already playing.
258        #[unsafe(method(play:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn play(&self, sender: Option<&AnyObject>);
261
262        /// This action method pauses the scene playback.
263        ///
264        /// Parameter `sender`: The object (such as a button or menu item) sending the message to pause the scene.
265        ///
266        /// This method does not do anything if the scene is already paused.
267        #[unsafe(method(pause:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn pause(&self, sender: Option<&AnyObject>);
270
271        /// This action method stops the scene playback and resets the current time to the start time of the scene.
272        ///
273        /// Parameter `sender`: The object (such as a button or menu item) sending the message to stop playing the scene.
274        #[unsafe(method(stop:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn stop(&self, sender: Option<&AnyObject>);
277
278        /// The rate you want the view to redraw its contents.
279        ///
280        /// When your application sets its preferred frame rate, the view chooses a frame rate as close to that as possible based on the capabilities of the screen the view is displayed on. The actual frame rate chosen is usually a factor of the maximum refresh rate of the screen to provide a consistent frame rate. For example, if the maximum refresh rate of the screen is 60 frames per second, that is also the highest frame rate the view sets as the actual frame rate. However, if you ask for a lower frame rate, it might choose 30, 20, 15 or some other factor to be the actual frame rate. Your application should choose a frame rate that it can consistently maintain.
281        /// The default value is 0 which means the display link will fire at the native cadence of the display hardware.
282        #[unsafe(method(preferredFramesPerSecond))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn preferredFramesPerSecond(&self) -> NSInteger;
285
286        /// Setter for [`preferredFramesPerSecond`][Self::preferredFramesPerSecond].
287        #[unsafe(method(setPreferredFramesPerSecond:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setPreferredFramesPerSecond(&self, preferred_frames_per_second: NSInteger);
290
291        /// Specifies whether the drawable is resized asynchonously during a live resize operation. Defaults to YES.
292        ///
293        /// If set to YES, the actual viewport size during a live resize can be retrieved using currentViewport (see SCNSceneRenderer.h)
294        #[unsafe(method(drawableResizesAsynchronously))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn drawableResizesAsynchronously(&self) -> bool;
297
298        /// Setter for [`drawableResizesAsynchronously`][Self::drawableResizesAsynchronously].
299        #[unsafe(method(setDrawableResizesAsynchronously:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn setDrawableResizesAsynchronously(
302            &self,
303            drawable_resizes_asynchronously: bool,
304        );
305
306        #[cfg(feature = "SCNSceneRenderer")]
307        /// Defaults to SCNAntialiasingModeMultisampling4X on macOS and SCNAntialiasingModeNone on iOS.
308        #[unsafe(method(antialiasingMode))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn antialiasingMode(&self) -> SCNAntialiasingMode;
311
312        #[cfg(feature = "SCNSceneRenderer")]
313        /// Setter for [`antialiasingMode`][Self::antialiasingMode].
314        #[unsafe(method(setAntialiasingMode:))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn setAntialiasingMode(&self, antialiasing_mode: SCNAntialiasingMode);
317    );
318}
319
320/// Methods declared on superclass `NSView`.
321#[cfg(feature = "objc2-app-kit")]
322#[cfg(target_os = "macos")]
323impl SCNView {
324    extern_methods!(
325        #[unsafe(method(initWithFrame:))]
326        #[unsafe(method_family = init)]
327        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
328
329        #[unsafe(method(initWithCoder:))]
330        #[unsafe(method_family = init)]
331        pub unsafe fn initWithCoder(
332            this: Allocated<Self>,
333            coder: &NSCoder,
334        ) -> Option<Retained<Self>>;
335    );
336}
337
338/// Methods declared on superclass `NSResponder`.
339#[cfg(feature = "objc2-app-kit")]
340#[cfg(target_os = "macos")]
341impl SCNView {
342    extern_methods!(
343        #[unsafe(method(init))]
344        #[unsafe(method_family = init)]
345        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
346    );
347}
348
349/// Methods declared on superclass `NSObject`.
350#[cfg(feature = "objc2-app-kit")]
351#[cfg(target_os = "macos")]
352impl SCNView {
353    extern_methods!(
354        #[unsafe(method(new))]
355        #[unsafe(method_family = new)]
356        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
357    );
358}