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-avf-audio")]
use objc2_avf_audio::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// A SpriteKit scene graph audio node that provides a way to link audio graphs to a SpriteKit scene.
    /// The currently presented scene is responsible for mixing the audio from nodes in the scene.
    ///
    /// Positional sounds will use their relative location and velocity to the scene's listener to apply distance
    /// attenuation, doppler shift and pan.
    ///
    ///
    /// See: AVAudio3DMixing
    ///
    /// See: SKScene.listener
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skaudionode?language=objc)
    #[unsafe(super(SKNode, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
    #[cfg(target_os = "macos")]
    pub struct SKAudioNode;
);

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

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCopying for SKAudioNode {}
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
unsafe impl CopyingHelper for SKAudioNode {
    type Result = Self;
}

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

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

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
impl SKAudioNode {
    extern_methods!(
        #[cfg(feature = "objc2-avf-audio")]
        /// Creates a SpriteKit scene graph audio node from the given AVAudioNode.
        ///
        /// See: AVAudioNode
        #[unsafe(method(initWithAVAudioNode:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAVAudioNode(
            this: Allocated<Self>,
            node: Option<&AVAudioNode>,
        ) -> Retained<Self>;

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

        /// Convenience initializer that creates an AVAudioNode from the named audio asset in the main bundle.
        ///
        /// See: initWithAVAudioNode
        #[unsafe(method(initWithFileNamed:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFileNamed(this: Allocated<Self>, name: &NSString) -> Retained<Self>;

        /// Convenience initializer that creates an AVAudioNode from the URL that contain a audio asset.
        ///
        /// See: initWithAVAudioNode
        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;

        #[cfg(feature = "objc2-avf-audio")]
        /// Sets or gets the current AVAudioNode used by this instance.
        #[unsafe(method(avAudioNode))]
        #[unsafe(method_family = none)]
        pub unsafe fn avAudioNode(&self) -> Option<Retained<AVAudioNode>>;

        #[cfg(feature = "objc2-avf-audio")]
        /// Setter for [`avAudioNode`][Self::avAudioNode].
        #[unsafe(method(setAvAudioNode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAvAudioNode(&self, av_audio_node: Option<&AVAudioNode>);

        /// Specifies whether the node is to automatically play sound when added to a scene.
        /// If autoplaysLooped is NO, the node and its sound must be explicitly scheduled and played using
        /// the scene's engine.
        ///
        /// If YES, the node will automatically play sound when added to a scene.
        ///
        /// Defaults to YES.
        ///
        /// See: SKView.paused
        #[unsafe(method(autoplayLooped))]
        #[unsafe(method_family = none)]
        pub unsafe fn autoplayLooped(&self) -> bool;

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

        /// Marks the audio source as positional so that the audio mix considers relative position and velocity
        /// with regards to the scene's current listener node.
        ///
        ///
        /// See: AVAudio3DMixing
        ///
        /// See: SKScene.listener
        #[unsafe(method(isPositional))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPositional(&self) -> bool;

        /// Setter for [`isPositional`][Self::isPositional].
        #[unsafe(method(setPositional:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPositional(&self, positional: bool);
    );
}

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

        #[unsafe(method(node))]
        #[unsafe(method_family = none)]
        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;

        #[unsafe(method(nodeWithFileNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeWithFileNamed(
            filename: &NSString,
            mtm: MainThreadMarker,
        ) -> Option<Retained<Self>>;

        /// # Safety
        ///
        /// `classes` generic probably has further requirements.
        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
            filename: &NSString,
            classes: &NSSet<AnyClass>,
            mtm: MainThreadMarker,
        ) -> Result<Retained<Self>, Retained<NSError>>;
    );
}

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

/// SKAudioNode.
///
/// Actions that are to be used with audio nodes.
#[cfg(feature = "SKAction")]
impl SKAction {
    extern_methods!(
        #[unsafe(method(stereoPanTo:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stereoPanTo_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(stereoPanBy:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stereoPanBy_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeReverbTo:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeReverbTo_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeReverbBy:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeReverbBy_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeObstructionTo:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeObstructionTo_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeObstructionBy:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeObstructionBy_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeOcclusionTo:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeOcclusionTo_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;

        #[unsafe(method(changeOcclusionBy:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn changeOcclusionBy_duration(
            v: c_float,
            duration: NSTimeInterval,
        ) -> Retained<SKAction>;
    );
}