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")]
122extern_conformance!(
123    unsafe impl NSAccessibility for SCNView {}
124);
125
126#[cfg(feature = "objc2-app-kit")]
127#[cfg(target_os = "macos")]
128extern_conformance!(
129    unsafe impl NSAccessibilityElementProtocol for SCNView {}
130);
131
132#[cfg(feature = "objc2-app-kit")]
133#[cfg(target_os = "macos")]
134extern_conformance!(
135    unsafe impl NSAnimatablePropertyContainer for SCNView {}
136);
137
138#[cfg(feature = "objc2-app-kit")]
139#[cfg(target_os = "macos")]
140extern_conformance!(
141    unsafe impl NSAppearanceCustomization for SCNView {}
142);
143
144#[cfg(feature = "objc2-app-kit")]
145#[cfg(target_os = "macos")]
146extern_conformance!(
147    unsafe impl NSCoding for SCNView {}
148);
149
150#[cfg(feature = "objc2-app-kit")]
151#[cfg(target_os = "macos")]
152extern_conformance!(
153    unsafe impl NSDraggingDestination for SCNView {}
154);
155
156#[cfg(feature = "objc2-app-kit")]
157#[cfg(target_os = "macos")]
158extern_conformance!(
159    unsafe impl NSObjectProtocol for SCNView {}
160);
161
162#[cfg(feature = "objc2-app-kit")]
163#[cfg(target_os = "macos")]
164extern_conformance!(
165    unsafe impl NSUserInterfaceItemIdentification for SCNView {}
166);
167
168#[cfg(all(feature = "SCNSceneRenderer", feature = "objc2-app-kit"))]
169#[cfg(target_os = "macos")]
170extern_conformance!(
171    unsafe impl SCNSceneRenderer for SCNView {}
172);
173
174#[cfg(all(feature = "SCNTechnique", feature = "objc2-app-kit"))]
175#[cfg(target_os = "macos")]
176extern_conformance!(
177    unsafe impl SCNTechniqueSupport for SCNView {}
178);
179
180#[cfg(feature = "objc2-app-kit")]
181#[cfg(target_os = "macos")]
182impl SCNView {
183    extern_methods!(
184        /// Initializes and returns a newly allocated SCNView object with a specified frame rectangle.
185        ///
186        /// Parameter `frame`: The frame rectangle for the created view object.
187        ///
188        /// Parameter `options`: An optional dictionary. See "View initialization options" above.
189        ///
190        /// # Safety
191        ///
192        /// `options` generic should be of the correct type.
193        #[unsafe(method(initWithFrame:options:))]
194        #[unsafe(method_family = init)]
195        pub unsafe fn initWithFrame_options(
196            this: Allocated<Self>,
197            frame: NSRect,
198            options: Option<&NSDictionary<NSString, AnyObject>>,
199        ) -> Retained<Self>;
200
201        #[cfg(feature = "SCNScene")]
202        /// Specifies the scene of the receiver
203        #[unsafe(method(scene))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn scene(&self) -> Option<Retained<SCNScene>>;
206
207        #[cfg(feature = "SCNScene")]
208        /// Setter for [`scene`][Self::scene].
209        #[unsafe(method(setScene:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn setScene(&self, scene: Option<&SCNScene>);
212
213        /// 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.
214        #[unsafe(method(rendersContinuously))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn rendersContinuously(&self) -> bool;
217
218        /// Setter for [`rendersContinuously`][Self::rendersContinuously].
219        #[unsafe(method(setRendersContinuously:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn setRendersContinuously(&self, renders_continuously: bool);
222
223        /// Specifies the background color of the receiver. Defaults to opaque white.
224        #[unsafe(method(backgroundColor))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn backgroundColor(&self) -> Retained<NSColor>;
227
228        /// Setter for [`backgroundColor`][Self::backgroundColor].
229        ///
230        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
231        #[unsafe(method(setBackgroundColor:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn setBackgroundColor(&self, background_color: &NSColor);
234
235        /// A Boolean value that determines whether the user can manipulate the point of view used to render the scene.
236        ///
237        /// 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.
238        /// 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.
239        /// The built-in camera controller let you:
240        /// - drag the mouse to rotate the camera around the scene
241        /// - drag+cmd to rotate the camera in local space
242        /// - drag+shift to rotate using sticky axis
243        /// - use the scroll wheel or alt+drag the mouse to translate the camera on its local X,Y plan
244        /// - alt+scroll wheel to move the camera forward/backward
245        /// - rotate gesture (trackpad only) to roll the camera (rotation around the Z axis)
246        /// - pinch gesture (trackpad only) move the camera forward/backward
247        /// - alt + pinch gesture (trackpad only) to zoom-in / zoom-out (change the field of view of the camera)
248        #[unsafe(method(allowsCameraControl))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn allowsCameraControl(&self) -> bool;
251
252        /// Setter for [`allowsCameraControl`][Self::allowsCameraControl].
253        #[unsafe(method(setAllowsCameraControl:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn setAllowsCameraControl(&self, allows_camera_control: bool);
256
257        /// An object describing the current configuration of the event handler which pilot the default camera controller.
258        ///
259        /// This object will be used to configure the event handler when allowCameraControl is set to YES.
260        #[unsafe(method(cameraControlConfiguration))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn cameraControlConfiguration(
263            &self,
264        ) -> Retained<ProtocolObject<dyn SCNCameraControlConfiguration>>;
265
266        #[cfg(feature = "SCNCameraController")]
267        /// Returns the default SCNCameraController used to drive the current point of view when allowCameraController is set to YES.
268        #[unsafe(method(defaultCameraController))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn defaultCameraController(&self) -> Retained<SCNCameraController>;
271
272        /// Draws the contents of the view and returns them as a new image object
273        ///
274        /// This method is thread-safe and may be called at any time.
275        #[unsafe(method(snapshot))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn snapshot(&self) -> Retained<NSImage>;
278
279        /// This action method begins playing the scene at its current location.
280        ///
281        /// Parameter `sender`: The object (such as a button or menu item) sending the message to play the scene.
282        ///
283        /// This method does not do anything if the scene is already playing.
284        ///
285        /// # Safety
286        ///
287        /// `sender` should be of the correct type.
288        #[unsafe(method(play:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn play(&self, sender: Option<&AnyObject>);
291
292        /// This action method pauses the scene playback.
293        ///
294        /// Parameter `sender`: The object (such as a button or menu item) sending the message to pause the scene.
295        ///
296        /// This method does not do anything if the scene is already paused.
297        ///
298        /// # Safety
299        ///
300        /// `sender` should be of the correct type.
301        #[unsafe(method(pause:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn pause(&self, sender: Option<&AnyObject>);
304
305        /// This action method stops the scene playback and resets the current time to the start time of the scene.
306        ///
307        /// Parameter `sender`: The object (such as a button or menu item) sending the message to stop playing the scene.
308        ///
309        /// # Safety
310        ///
311        /// `sender` should be of the correct type.
312        #[unsafe(method(stop:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn stop(&self, sender: Option<&AnyObject>);
315
316        /// The rate you want the view to redraw its contents.
317        ///
318        /// 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.
319        /// The default value is 0 which means the display link will fire at the native cadence of the display hardware.
320        #[unsafe(method(preferredFramesPerSecond))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn preferredFramesPerSecond(&self) -> NSInteger;
323
324        /// Setter for [`preferredFramesPerSecond`][Self::preferredFramesPerSecond].
325        #[unsafe(method(setPreferredFramesPerSecond:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn setPreferredFramesPerSecond(&self, preferred_frames_per_second: NSInteger);
328
329        /// Specifies whether the drawable is resized asynchonously during a live resize operation. Defaults to YES.
330        ///
331        /// If set to YES, the actual viewport size during a live resize can be retrieved using currentViewport (see SCNSceneRenderer.h)
332        #[unsafe(method(drawableResizesAsynchronously))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn drawableResizesAsynchronously(&self) -> bool;
335
336        /// Setter for [`drawableResizesAsynchronously`][Self::drawableResizesAsynchronously].
337        #[unsafe(method(setDrawableResizesAsynchronously:))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn setDrawableResizesAsynchronously(
340            &self,
341            drawable_resizes_asynchronously: bool,
342        );
343
344        /// Specifies the OpenGL context associated with the receiver.
345        ///
346        /// This property returns nil and has no effect if the current API is Metal.
347        #[deprecated = "OpenGL API deprecated, please use Metal instead. (Define SCN_SILENCE_GL_DEPRECATION to silence these warnings)"]
348        #[unsafe(method(openGLContext))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn openGLContext(&self) -> Option<Retained<NSOpenGLContext>>;
351
352        /// Setter for [`openGLContext`][Self::openGLContext].
353        #[deprecated = "OpenGL API deprecated, please use Metal instead. (Define SCN_SILENCE_GL_DEPRECATION to silence these warnings)"]
354        #[unsafe(method(setOpenGLContext:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn setOpenGLContext(&self, open_gl_context: Option<&NSOpenGLContext>);
357
358        #[cfg(feature = "SCNSceneRenderer")]
359        /// Defaults to SCNAntialiasingModeMultisampling4X on macOS and SCNAntialiasingModeNone on iOS.
360        #[unsafe(method(antialiasingMode))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn antialiasingMode(&self) -> SCNAntialiasingMode;
363
364        #[cfg(feature = "SCNSceneRenderer")]
365        /// Setter for [`antialiasingMode`][Self::antialiasingMode].
366        #[unsafe(method(setAntialiasingMode:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn setAntialiasingMode(&self, antialiasing_mode: SCNAntialiasingMode);
369
370        /// Specifies the pixel format of the receiver.
371        ///
372        /// This property returns nil and has no effect if the current API is Metal.
373        #[deprecated = "OpenGL API deprecated, please use Metal instead. (Define SCN_SILENCE_GL_DEPRECATION to silence these warnings)"]
374        #[unsafe(method(pixelFormat))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn pixelFormat(&self) -> Option<Retained<NSOpenGLPixelFormat>>;
377
378        /// Setter for [`pixelFormat`][Self::pixelFormat].
379        #[deprecated = "OpenGL API deprecated, please use Metal instead. (Define SCN_SILENCE_GL_DEPRECATION to silence these warnings)"]
380        #[unsafe(method(setPixelFormat:))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn setPixelFormat(&self, pixel_format: Option<&NSOpenGLPixelFormat>);
383    );
384}
385
386/// Methods declared on superclass `NSView`.
387#[cfg(feature = "objc2-app-kit")]
388#[cfg(target_os = "macos")]
389impl SCNView {
390    extern_methods!(
391        #[unsafe(method(initWithFrame:))]
392        #[unsafe(method_family = init)]
393        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
394
395        /// # Safety
396        ///
397        /// `coder` possibly has further requirements.
398        #[unsafe(method(initWithCoder:))]
399        #[unsafe(method_family = init)]
400        pub unsafe fn initWithCoder(
401            this: Allocated<Self>,
402            coder: &NSCoder,
403        ) -> Option<Retained<Self>>;
404    );
405}
406
407/// Methods declared on superclass `NSResponder`.
408#[cfg(feature = "objc2-app-kit")]
409#[cfg(target_os = "macos")]
410impl SCNView {
411    extern_methods!(
412        #[unsafe(method(init))]
413        #[unsafe(method_family = init)]
414        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
415    );
416}
417
418/// Methods declared on superclass `NSObject`.
419#[cfg(feature = "objc2-app-kit")]
420#[cfg(target_os = "macos")]
421impl SCNView {
422    extern_methods!(
423        #[unsafe(method(new))]
424        #[unsafe(method_family = new)]
425        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
426    );
427}