objc2-sprite-kit 0.3.2

Bindings to the SpriteKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    #[cfg(target_os = "macos")]
    pub struct SKView;
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibility for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCoding for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSDraggingDestination for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSObjectProtocol for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSSecureCoding for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for SKView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SKView {
    extern_methods!(
        /// Pause the entire view
        #[unsafe(method(isPaused))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPaused(&self) -> bool;

        /// Setter for [`isPaused`][Self::isPaused].
        #[unsafe(method(setPaused:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPaused(&self, paused: bool);

        /// Toggles display of performance stats in the view. All default to false.
        #[unsafe(method(showsFPS))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsFPS(&self) -> bool;

        /// Setter for [`showsFPS`][Self::showsFPS].
        #[unsafe(method(setShowsFPS:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsFPS(&self, shows_fps: bool);

        #[unsafe(method(showsDrawCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsDrawCount(&self) -> bool;

        /// Setter for [`showsDrawCount`][Self::showsDrawCount].
        #[unsafe(method(setShowsDrawCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsDrawCount(&self, shows_draw_count: bool);

        #[unsafe(method(showsNodeCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsNodeCount(&self) -> bool;

        /// Setter for [`showsNodeCount`][Self::showsNodeCount].
        #[unsafe(method(setShowsNodeCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsNodeCount(&self, shows_node_count: bool);

        #[unsafe(method(showsQuadCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsQuadCount(&self) -> bool;

        /// Setter for [`showsQuadCount`][Self::showsQuadCount].
        #[unsafe(method(setShowsQuadCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsQuadCount(&self, shows_quad_count: bool);

        #[unsafe(method(showsPhysics))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsPhysics(&self) -> bool;

        /// Setter for [`showsPhysics`][Self::showsPhysics].
        #[unsafe(method(setShowsPhysics:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsPhysics(&self, shows_physics: bool);

        #[unsafe(method(showsFields))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsFields(&self) -> bool;

        /// Setter for [`showsFields`][Self::showsFields].
        #[unsafe(method(setShowsFields:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsFields(&self, shows_fields: bool);

        /// Toggles whether the view updates is rendered asynchronously or aligned with Core Animation updates. Defaults to YES.
        #[unsafe(method(isAsynchronous))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAsynchronous(&self) -> bool;

        /// Setter for [`isAsynchronous`][Self::isAsynchronous].
        #[unsafe(method(setAsynchronous:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAsynchronous(&self, asynchronous: bool);

        /// Toggles whether the view allows transparent rendering. This allows content under the view to show through if
        /// a non-opaque backgroundColor is set on the scene. Defaults to NO.
        #[unsafe(method(allowsTransparency))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsTransparency(&self) -> bool;

        /// Setter for [`allowsTransparency`][Self::allowsTransparency].
        #[unsafe(method(setAllowsTransparency:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAllowsTransparency(&self, allows_transparency: bool);

        /// Ignores sibling and traversal order to sort the rendered contents of a scene into the most efficient batching possible.
        /// This will require zPosition to be used in the scenes to properly guarantee elements are in front or behind each other.
        ///
        /// This defaults to NO, meaning that sibling order overrides efficiency heuristics in the rendering of the scenes in the view.
        ///
        /// Setting this to YES for a complex scene may substantially increase performance, but care must be taken as only zPosition
        /// determines render order before the efficiency heuristics are used.
        #[unsafe(method(ignoresSiblingOrder))]
        #[unsafe(method_family = none)]
        pub unsafe fn ignoresSiblingOrder(&self) -> bool;

        /// Setter for [`ignoresSiblingOrder`][Self::ignoresSiblingOrder].
        #[unsafe(method(setIgnoresSiblingOrder:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIgnoresSiblingOrder(&self, ignores_sibling_order: bool);

        #[unsafe(method(shouldCullNonVisibleNodes))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldCullNonVisibleNodes(&self) -> bool;

        /// Setter for [`shouldCullNonVisibleNodes`][Self::shouldCullNonVisibleNodes].
        #[unsafe(method(setShouldCullNonVisibleNodes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShouldCullNonVisibleNodes(&self, should_cull_non_visible_nodes: bool);

        #[unsafe(method(preferredFramesPerSecond))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredFramesPerSecond(&self) -> NSInteger;

        /// Setter for [`preferredFramesPerSecond`][Self::preferredFramesPerSecond].
        #[unsafe(method(setPreferredFramesPerSecond:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredFramesPerSecond(&self, preferred_frames_per_second: NSInteger);

        #[unsafe(method(disableDepthStencilBuffer))]
        #[unsafe(method_family = none)]
        pub unsafe fn disableDepthStencilBuffer(&self) -> bool;

        /// Setter for [`disableDepthStencilBuffer`][Self::disableDepthStencilBuffer].
        #[unsafe(method(setDisableDepthStencilBuffer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisableDepthStencilBuffer(&self, disable_depth_stencil_buffer: bool);

        /// Optional view delegate, see SKViewDelegate.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<NSObject>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `delegate` must implement SKViewDelegate.
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&NSObject>);

        #[deprecated]
        #[unsafe(method(frameInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameInterval(&self) -> NSInteger;

        /// Setter for [`frameInterval`][Self::frameInterval].
        #[deprecated]
        #[unsafe(method(setFrameInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFrameInterval(&self, frame_interval: NSInteger);

        #[deprecated]
        #[unsafe(method(preferredFrameRate))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredFrameRate(&self) -> c_float;

        /// Setter for [`preferredFrameRate`][Self::preferredFrameRate].
        #[deprecated]
        #[unsafe(method(setPreferredFrameRate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredFrameRate(&self, preferred_frame_rate: c_float);

        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
        /// Present an SKScene in the view, replacing the current scene.
        ///
        ///
        /// Parameter `scene`: the scene to present.
        #[unsafe(method(presentScene:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentScene(&self, scene: Option<&SKScene>);

        #[cfg(all(
            feature = "SKEffectNode",
            feature = "SKNode",
            feature = "SKScene",
            feature = "SKTransition"
        ))]
        /// Present an SKScene in the view, replacing the current scene.
        ///
        /// If there is currently a scene being presented in the view, the transition is used to swap between them.
        ///
        ///
        /// Parameter `scene`: the scene to present.
        ///
        /// Parameter `transition`: the transition to use when presenting the scene.
        #[unsafe(method(presentScene:transition:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentScene_transition(&self, scene: &SKScene, transition: &SKTransition);

        #[cfg(all(feature = "SKEffectNode", feature = "SKNode", feature = "SKScene"))]
        /// The currently presented scene, otherwise nil. If in a transition, the 'incoming' scene is returned.
        #[unsafe(method(scene))]
        #[unsafe(method_family = none)]
        pub unsafe fn scene(&self) -> Option<Retained<SKScene>>;

        #[cfg(all(feature = "SKNode", feature = "SKTexture"))]
        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
        /// The texture is tightly cropped to the size of the node.
        ///
        /// Parameter `node`: the node subtree to render to the texture.
        #[unsafe(method(textureFromNode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureFromNode(&self, node: &SKNode) -> Option<Retained<SKTexture>>;

        #[cfg(all(
            feature = "SKNode",
            feature = "SKTexture",
            feature = "objc2-core-foundation"
        ))]
        /// Create an SKTexture containing a snapshot of how it would have been rendered in this view.
        /// The texture is cropped to the specified rectangle
        ///
        /// Parameter `node`: the node subtree to render to the texture.
        ///
        /// Parameter `crop`: the crop
        #[unsafe(method(textureFromNode:crop:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureFromNode_crop(
            &self,
            node: &SKNode,
            crop: CGRect,
        ) -> Option<Retained<SKTexture>>;

        #[cfg(all(
            feature = "SKEffectNode",
            feature = "SKNode",
            feature = "SKScene",
            feature = "objc2-core-foundation"
        ))]
        /// Converts a point from view space to scene space.
        ///
        ///
        /// Parameter `point`: the point to convert.
        ///
        /// Parameter `scene`: the scene to convert the point into.
        #[unsafe(method(convertPoint:toScene:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertPoint_toScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;

        #[cfg(all(
            feature = "SKEffectNode",
            feature = "SKNode",
            feature = "SKScene",
            feature = "objc2-core-foundation"
        ))]
        /// Converts a point from scene space to view space.
        ///
        ///
        /// Parameter `point`: the point to convert.
        ///
        /// Parameter `scene`: the scene to convert the point into.
        #[unsafe(method(convertPoint:fromScene:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertPoint_fromScene(&self, point: CGPoint, scene: &SKScene) -> CGPoint;
    );
}

/// Methods declared on superclass `NSView`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SKView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SKView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl SKView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skviewdelegate?language=objc)
    pub unsafe trait SKViewDelegate: NSObjectProtocol {
        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// Allows the client to dynamically control the render rate.
        ///
        /// return YES to initiate an update and render for the target time.
        /// return NO to skip update and render for this target time.
        #[optional]
        #[unsafe(method(view:shouldRenderAtTime:))]
        #[unsafe(method_family = none)]
        unsafe fn view_shouldRenderAtTime(&self, view: &SKView, time: NSTimeInterval) -> bool;
    }
);