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        /// Setter for [`delegate`][Self::delegate].
217        ///
218        /// This is a [weak property][objc2::topics::weak_property].
219        ///
220        /// # Safety
221        ///
222        /// `delegate` must implement SKViewDelegate.
223        #[unsafe(method(setDelegate:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setDelegate(&self, delegate: Option<&NSObject>);
226
227        #[deprecated]
228        #[unsafe(method(frameInterval))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn frameInterval(&self) -> NSInteger;
231
232        /// Setter for [`frameInterval`][Self::frameInterval].
233        #[deprecated]
234        #[unsafe(method(setFrameInterval:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn setFrameInterval(&self, frame_interval: NSInteger);
237
238        #[deprecated]
239        #[unsafe(method(preferredFrameRate))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn preferredFrameRate(&self) -> c_float;
242
243        /// Setter for [`preferredFrameRate`][Self::preferredFrameRate].
244        #[deprecated]
245        #[unsafe(method(setPreferredFrameRate:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setPreferredFrameRate(&self, preferred_frame_rate: c_float);
248
249        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
250        /// Present an SKScene in the view, replacing the current scene.
251        ///
252        ///
253        /// Parameter `scene`: the scene to present.
254        #[unsafe(method(presentScene:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn presentScene(&self, scene: Option<&SKScene>);
257
258        #[cfg(all(
259            feature = "SKEffectNode",
260            feature = "SKNode",
261            feature = "SKScene",
262            feature = "SKTransition"
263        ))]
264        /// Present an SKScene in the view, replacing the current scene.
265        ///
266        /// If there is currently a scene being presented in the view, the transition is used to swap between them.
267        ///
268        ///
269        /// Parameter `scene`: the scene to present.
270        ///
271        /// Parameter `transition`: the transition to use when presenting the scene.
272        #[unsafe(method(presentScene:transition:))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn presentScene_transition(&self, scene: &SKScene, transition: &SKTransition);
275
276        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
277        /// The currently presented scene, otherwise nil. If in a transition, the 'incoming' scene is returned.
278        #[unsafe(method(scene))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn scene(&self) -> Option<Retained<SKScene>>;
281
282        #[cfg(all(feature = "SKNode", feature = "SKTexture"))]
283        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
284        /// The texture is tightly cropped to the size of the node.
285        ///
286        /// Parameter `node`: the node subtree to render to the texture.
287        #[unsafe(method(textureFromNode:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn textureFromNode(&self, node: &SKNode) -> Option<Retained<SKTexture>>;
290
291        #[cfg(all(
292            feature = "SKNode",
293            feature = "SKTexture",
294            feature = "objc2-core-foundation"
295        ))]
296        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
297        /// The texture is cropped to the specified rectangle
298        ///
299        /// Parameter `node`: the node subtree to render to the texture.
300        ///
301        /// Parameter `crop`: the crop
302        #[unsafe(method(textureFromNode:crop:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn textureFromNode_crop(
305            &self,
306            node: &SKNode,
307            crop: CGRect,
308        ) -> Option<Retained<SKTexture>>;
309
310        #[cfg(all(
311            feature = "SKEffectNode",
312            feature = "SKNode",
313            feature = "SKScene",
314            feature = "objc2-core-foundation"
315        ))]
316        /// Converts a point from view space to scene space.
317        ///
318        ///
319        /// Parameter `point`: the point to convert.
320        ///
321        /// Parameter `scene`: the scene to convert the point into.
322        #[unsafe(method(convertPoint:toScene:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn convertPoint_toScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;
325
326        #[cfg(all(
327            feature = "SKEffectNode",
328            feature = "SKNode",
329            feature = "SKScene",
330            feature = "objc2-core-foundation"
331        ))]
332        /// Converts a point from scene space to view space.
333        ///
334        ///
335        /// Parameter `point`: the point to convert.
336        ///
337        /// Parameter `scene`: the scene to convert the point into.
338        #[unsafe(method(convertPoint:fromScene:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn convertPoint_fromScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;
341    );
342}
343
344/// Methods declared on superclass `NSView`.
345#[cfg(feature = "objc2-app-kit")]
346#[cfg(target_os = "macos")]
347impl SKView {
348    extern_methods!(
349        #[unsafe(method(initWithFrame:))]
350        #[unsafe(method_family = init)]
351        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
352
353        /// # Safety
354        ///
355        /// `coder` possibly has further requirements.
356        #[unsafe(method(initWithCoder:))]
357        #[unsafe(method_family = init)]
358        pub unsafe fn initWithCoder(
359            this: Allocated<Self>,
360            coder: &NSCoder,
361        ) -> Option<Retained<Self>>;
362    );
363}
364
365/// Methods declared on superclass `NSResponder`.
366#[cfg(feature = "objc2-app-kit")]
367#[cfg(target_os = "macos")]
368impl SKView {
369    extern_methods!(
370        #[unsafe(method(init))]
371        #[unsafe(method_family = init)]
372        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
373    );
374}
375
376/// Methods declared on superclass `NSObject`.
377#[cfg(feature = "objc2-app-kit")]
378#[cfg(target_os = "macos")]
379impl SKView {
380    extern_methods!(
381        #[unsafe(method(new))]
382        #[unsafe(method_family = new)]
383        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
384    );
385}
386
387extern_protocol!(
388    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skviewdelegate?language=objc)
389    pub unsafe trait SKViewDelegate: NSObjectProtocol {
390        #[cfg(feature = "objc2-app-kit")]
391        #[cfg(target_os = "macos")]
392        /// Allows the client to dynamically control the render rate.
393        ///
394        /// return YES to initiate an update and render for the target time.
395        /// return NO to skip update and render for this target time.
396        #[optional]
397        #[unsafe(method(view:shouldRenderAtTime:))]
398        #[unsafe(method_family = none)]
399        unsafe fn view_shouldRenderAtTime(&self, view: &SKView, time: NSTimeInterval) -> bool;
400    }
401);