objc2_sprite_kit/generated/
SKView.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
15extern_class!(
16    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skview?language=objc)
17    #[unsafe(super(NSView, NSResponder, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(feature = "objc2-app-kit")]
20    #[cfg(target_os = "macos")]
21    pub struct SKView;
22);
23
24#[cfg(feature = "objc2-app-kit")]
25#[cfg(target_os = "macos")]
26unsafe impl NSAccessibility for SKView {}
27
28#[cfg(feature = "objc2-app-kit")]
29#[cfg(target_os = "macos")]
30unsafe impl NSAccessibilityElementProtocol for SKView {}
31
32#[cfg(feature = "objc2-app-kit")]
33#[cfg(target_os = "macos")]
34unsafe impl NSAnimatablePropertyContainer for SKView {}
35
36#[cfg(feature = "objc2-app-kit")]
37#[cfg(target_os = "macos")]
38unsafe impl NSAppearanceCustomization for SKView {}
39
40#[cfg(feature = "objc2-app-kit")]
41#[cfg(target_os = "macos")]
42unsafe impl NSCoding for SKView {}
43
44#[cfg(feature = "objc2-app-kit")]
45#[cfg(target_os = "macos")]
46unsafe impl NSDraggingDestination for SKView {}
47
48#[cfg(feature = "objc2-app-kit")]
49#[cfg(target_os = "macos")]
50unsafe impl NSObjectProtocol for SKView {}
51
52#[cfg(feature = "objc2-app-kit")]
53#[cfg(target_os = "macos")]
54unsafe impl NSSecureCoding for SKView {}
55
56#[cfg(feature = "objc2-app-kit")]
57#[cfg(target_os = "macos")]
58unsafe impl NSUserInterfaceItemIdentification for SKView {}
59
60#[cfg(feature = "objc2-app-kit")]
61#[cfg(target_os = "macos")]
62impl SKView {
63    extern_methods!(
64        /// Pause the entire view
65        #[unsafe(method(isPaused))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn isPaused(&self) -> bool;
68
69        /// Setter for [`isPaused`][Self::isPaused].
70        #[unsafe(method(setPaused:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setPaused(&self, paused: bool);
73
74        /// Toggles display of performance stats in the view. All default to false.
75        #[unsafe(method(showsFPS))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn showsFPS(&self) -> bool;
78
79        /// Setter for [`showsFPS`][Self::showsFPS].
80        #[unsafe(method(setShowsFPS:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setShowsFPS(&self, shows_fps: bool);
83
84        #[unsafe(method(showsDrawCount))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn showsDrawCount(&self) -> bool;
87
88        /// Setter for [`showsDrawCount`][Self::showsDrawCount].
89        #[unsafe(method(setShowsDrawCount:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn setShowsDrawCount(&self, shows_draw_count: bool);
92
93        #[unsafe(method(showsNodeCount))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn showsNodeCount(&self) -> bool;
96
97        /// Setter for [`showsNodeCount`][Self::showsNodeCount].
98        #[unsafe(method(setShowsNodeCount:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setShowsNodeCount(&self, shows_node_count: bool);
101
102        #[unsafe(method(showsQuadCount))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn showsQuadCount(&self) -> bool;
105
106        /// Setter for [`showsQuadCount`][Self::showsQuadCount].
107        #[unsafe(method(setShowsQuadCount:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setShowsQuadCount(&self, shows_quad_count: bool);
110
111        #[unsafe(method(showsPhysics))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn showsPhysics(&self) -> bool;
114
115        /// Setter for [`showsPhysics`][Self::showsPhysics].
116        #[unsafe(method(setShowsPhysics:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setShowsPhysics(&self, shows_physics: bool);
119
120        #[unsafe(method(showsFields))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn showsFields(&self) -> bool;
123
124        /// Setter for [`showsFields`][Self::showsFields].
125        #[unsafe(method(setShowsFields:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn setShowsFields(&self, shows_fields: bool);
128
129        /// Toggles whether the view updates is rendered asynchronously or aligned with Core Animation updates. Defaults to YES.
130        #[unsafe(method(isAsynchronous))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn isAsynchronous(&self) -> bool;
133
134        /// Setter for [`isAsynchronous`][Self::isAsynchronous].
135        #[unsafe(method(setAsynchronous:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setAsynchronous(&self, asynchronous: bool);
138
139        /// Toggles whether the view allows transparent rendering. This allows content under the view to show through if
140        /// a non-opaque backgroundColor is set on the scene. Defaults to NO.
141        #[unsafe(method(allowsTransparency))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn allowsTransparency(&self) -> bool;
144
145        /// Setter for [`allowsTransparency`][Self::allowsTransparency].
146        #[unsafe(method(setAllowsTransparency:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setAllowsTransparency(&self, allows_transparency: bool);
149
150        /// Ignores sibling and traversal order to sort the rendered contents of a scene into the most efficient batching possible.
151        /// This will require zPosition to be used in the scenes to properly guarantee elements are in front or behind each other.
152        ///
153        /// This defaults to NO, meaning that sibling order overrides efficiency heuristics in the rendering of the scenes in the view.
154        ///
155        /// Setting this to YES for a complex scene may substantially increase performance, but care must be taken as only zPosition
156        /// determines render order before the efficiency heuristics are used.
157        #[unsafe(method(ignoresSiblingOrder))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn ignoresSiblingOrder(&self) -> bool;
160
161        /// Setter for [`ignoresSiblingOrder`][Self::ignoresSiblingOrder].
162        #[unsafe(method(setIgnoresSiblingOrder:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setIgnoresSiblingOrder(&self, ignores_sibling_order: bool);
165
166        #[unsafe(method(shouldCullNonVisibleNodes))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn shouldCullNonVisibleNodes(&self) -> bool;
169
170        /// Setter for [`shouldCullNonVisibleNodes`][Self::shouldCullNonVisibleNodes].
171        #[unsafe(method(setShouldCullNonVisibleNodes:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setShouldCullNonVisibleNodes(&self, should_cull_non_visible_nodes: bool);
174
175        #[unsafe(method(preferredFramesPerSecond))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn preferredFramesPerSecond(&self) -> NSInteger;
178
179        /// Setter for [`preferredFramesPerSecond`][Self::preferredFramesPerSecond].
180        #[unsafe(method(setPreferredFramesPerSecond:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn setPreferredFramesPerSecond(&self, preferred_frames_per_second: NSInteger);
183
184        #[unsafe(method(disableDepthStencilBuffer))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn disableDepthStencilBuffer(&self) -> bool;
187
188        /// Setter for [`disableDepthStencilBuffer`][Self::disableDepthStencilBuffer].
189        #[unsafe(method(setDisableDepthStencilBuffer:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setDisableDepthStencilBuffer(&self, disable_depth_stencil_buffer: bool);
192
193        /// Optional view delegate, see SKViewDelegate.
194        #[unsafe(method(delegate))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn delegate(&self) -> Option<Retained<NSObject>>;
197
198        /// This is a [weak property][objc2::topics::weak_property].
199        /// Setter for [`delegate`][Self::delegate].
200        #[unsafe(method(setDelegate:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setDelegate(&self, delegate: Option<&NSObject>);
203
204        #[deprecated]
205        #[unsafe(method(frameInterval))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn frameInterval(&self) -> NSInteger;
208
209        /// Setter for [`frameInterval`][Self::frameInterval].
210        #[deprecated]
211        #[unsafe(method(setFrameInterval:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn setFrameInterval(&self, frame_interval: NSInteger);
214
215        #[deprecated]
216        #[unsafe(method(preferredFrameRate))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn preferredFrameRate(&self) -> c_float;
219
220        /// Setter for [`preferredFrameRate`][Self::preferredFrameRate].
221        #[deprecated]
222        #[unsafe(method(setPreferredFrameRate:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setPreferredFrameRate(&self, preferred_frame_rate: c_float);
225
226        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
227        /// Present an SKScene in the view, replacing the current scene.
228        ///
229        ///
230        /// Parameter `scene`: the scene to present.
231        #[unsafe(method(presentScene:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn presentScene(&self, scene: Option<&SKScene>);
234
235        #[cfg(all(
236            feature = "SKEffectNode",
237            feature = "SKNode",
238            feature = "SKScene",
239            feature = "SKTransition"
240        ))]
241        /// Present an SKScene in the view, replacing the current scene.
242        ///
243        /// If there is currently a scene being presented in the view, the transition is used to swap between them.
244        ///
245        ///
246        /// Parameter `scene`: the scene to present.
247        ///
248        /// Parameter `transition`: the transition to use when presenting the scene.
249        #[unsafe(method(presentScene:transition:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn presentScene_transition(&self, scene: &SKScene, transition: &SKTransition);
252
253        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
254        /// The currently presented scene, otherwise nil. If in a transition, the 'incoming' scene is returned.
255        #[unsafe(method(scene))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn scene(&self) -> Option<Retained<SKScene>>;
258
259        #[cfg(all(feature = "SKNode", feature = "SKTexture"))]
260        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
261        /// The texture is tightly cropped to the size of the node.
262        ///
263        /// Parameter `node`: the node subtree to render to the texture.
264        #[unsafe(method(textureFromNode:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn textureFromNode(&self, node: &SKNode) -> Option<Retained<SKTexture>>;
267
268        #[cfg(all(
269            feature = "SKNode",
270            feature = "SKTexture",
271            feature = "objc2-core-foundation"
272        ))]
273        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
274        /// The texture is cropped to the specified rectangle
275        ///
276        /// Parameter `node`: the node subtree to render to the texture.
277        ///
278        /// Parameter `crop`: the crop
279        #[unsafe(method(textureFromNode:crop:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn textureFromNode_crop(
282            &self,
283            node: &SKNode,
284            crop: CGRect,
285        ) -> Option<Retained<SKTexture>>;
286
287        #[cfg(all(
288            feature = "SKEffectNode",
289            feature = "SKNode",
290            feature = "SKScene",
291            feature = "objc2-core-foundation"
292        ))]
293        /// Converts a point from view space to scene space.
294        ///
295        ///
296        /// Parameter `point`: the point to convert.
297        ///
298        /// Parameter `scene`: the scene to convert the point into.
299        #[unsafe(method(convertPoint:toScene:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn convertPoint_toScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;
302
303        #[cfg(all(
304            feature = "SKEffectNode",
305            feature = "SKNode",
306            feature = "SKScene",
307            feature = "objc2-core-foundation"
308        ))]
309        /// Converts a point from scene space to view space.
310        ///
311        ///
312        /// Parameter `point`: the point to convert.
313        ///
314        /// Parameter `scene`: the scene to convert the point into.
315        #[unsafe(method(convertPoint:fromScene:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn convertPoint_fromScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;
318    );
319}
320
321/// Methods declared on superclass `NSView`.
322#[cfg(feature = "objc2-app-kit")]
323#[cfg(target_os = "macos")]
324impl SKView {
325    extern_methods!(
326        #[unsafe(method(initWithFrame:))]
327        #[unsafe(method_family = init)]
328        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
329
330        #[unsafe(method(initWithCoder:))]
331        #[unsafe(method_family = init)]
332        pub unsafe fn initWithCoder(
333            this: Allocated<Self>,
334            coder: &NSCoder,
335        ) -> Option<Retained<Self>>;
336    );
337}
338
339/// Methods declared on superclass `NSResponder`.
340#[cfg(feature = "objc2-app-kit")]
341#[cfg(target_os = "macos")]
342impl SKView {
343    extern_methods!(
344        #[unsafe(method(init))]
345        #[unsafe(method_family = init)]
346        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
347    );
348}
349
350/// Methods declared on superclass `NSObject`.
351#[cfg(feature = "objc2-app-kit")]
352#[cfg(target_os = "macos")]
353impl SKView {
354    extern_methods!(
355        #[unsafe(method(new))]
356        #[unsafe(method_family = new)]
357        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
358    );
359}
360
361extern_protocol!(
362    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skviewdelegate?language=objc)
363    pub unsafe trait SKViewDelegate: NSObjectProtocol {
364        #[cfg(feature = "objc2-app-kit")]
365        #[cfg(target_os = "macos")]
366        /// Allows the client to dynamically control the render rate.
367        ///
368        /// return YES to initiate an update and render for the target time.
369        /// return NO to skip update and render for this target time.
370        #[optional]
371        #[unsafe(method(view:shouldRenderAtTime:))]
372        #[unsafe(method_family = none)]
373        unsafe fn view_shouldRenderAtTime(&self, view: &SKView, time: NSTimeInterval) -> bool;
374    }
375);