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