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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelverticalalignmentmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SKLabelVerticalAlignmentMode(pub NSInteger);
impl SKLabelVerticalAlignmentMode {
    #[doc(alias = "SKLabelVerticalAlignmentModeBaseline")]
    pub const Baseline: Self = Self(0);
    #[doc(alias = "SKLabelVerticalAlignmentModeCenter")]
    pub const Center: Self = Self(1);
    #[doc(alias = "SKLabelVerticalAlignmentModeTop")]
    pub const Top: Self = Self(2);
    #[doc(alias = "SKLabelVerticalAlignmentModeBottom")]
    pub const Bottom: Self = Self(3);
}

unsafe impl Encode for SKLabelVerticalAlignmentMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SKLabelVerticalAlignmentMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelhorizontalalignmentmode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SKLabelHorizontalAlignmentMode(pub NSInteger);
impl SKLabelHorizontalAlignmentMode {
    #[doc(alias = "SKLabelHorizontalAlignmentModeCenter")]
    pub const Center: Self = Self(0);
    #[doc(alias = "SKLabelHorizontalAlignmentModeLeft")]
    pub const Left: Self = Self(1);
    #[doc(alias = "SKLabelHorizontalAlignmentModeRight")]
    pub const Right: Self = Self(2);
}

unsafe impl Encode for SKLabelHorizontalAlignmentMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SKLabelHorizontalAlignmentMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A node that displays a text label with a given font.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelnode?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 SKLabelNode;
);

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

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

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

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

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

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
impl SKLabelNode {
    extern_methods!(
        #[unsafe(method(labelNodeWithText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn labelNodeWithText(
            text: Option<&NSString>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

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

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

        #[unsafe(method(initWithFontNamed:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFontNamed(
            this: Allocated<Self>,
            font_name: Option<&NSString>,
        ) -> Retained<Self>;

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

        /// Setter for [`verticalAlignmentMode`][Self::verticalAlignmentMode].
        #[unsafe(method(setVerticalAlignmentMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVerticalAlignmentMode(
            &self,
            vertical_alignment_mode: SKLabelVerticalAlignmentMode,
        );

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

        /// Setter for [`horizontalAlignmentMode`][Self::horizontalAlignmentMode].
        #[unsafe(method(setHorizontalAlignmentMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHorizontalAlignmentMode(
            &self,
            horizontal_alignment_mode: SKLabelHorizontalAlignmentMode,
        );

        /// Determines the number of lines to draw. The default value is 1 (single line). A value of 0 means no limit.
        /// If the height of the text reaches the # of lines the text will be truncated using the line break mode.
        #[unsafe(method(numberOfLines))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfLines(&self) -> NSInteger;

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

        /// Determines the line break mode for multiple lines.
        /// Default is NSLineBreakByTruncatingTail
        #[unsafe(method(lineBreakMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineBreakMode(&self) -> NSLineBreakMode;

        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
        #[unsafe(method(setLineBreakMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);

        #[cfg(feature = "objc2-core-foundation")]
        /// If nonzero, this is used when determining layout width for multiline labels.
        /// Default is zero.
        #[unsafe(method(preferredMaxLayoutWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMaxLayoutWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
        #[unsafe(method(setPreferredMaxLayoutWidth:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);

        #[unsafe(method(fontName))]
        #[unsafe(method_family = none)]
        pub unsafe fn fontName(&self) -> Option<Retained<NSString>>;

        /// Setter for [`fontName`][Self::fontName].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setFontName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFontName(&self, font_name: Option<&NSString>);

        #[unsafe(method(text))]
        #[unsafe(method_family = none)]
        pub unsafe fn text(&self) -> Option<Retained<NSString>>;

        /// Setter for [`text`][Self::text].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setText(&self, text: Option<&NSString>);

        #[unsafe(method(attributedText))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributedText(&self) -> Option<Retained<NSAttributedString>>;

        /// Setter for [`attributedText`][Self::attributedText].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAttributedText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(fontSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn fontSize(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`fontSize`][Self::fontSize].
        #[unsafe(method(setFontSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFontSize(&self, font_size: CGFloat);

        /// Base color that the text is rendered with (if supported by the font)
        #[unsafe(method(fontColor))]
        #[unsafe(method_family = none)]
        pub unsafe fn fontColor(&self) -> Option<Retained<NSColor>>;

        /// Setter for [`fontColor`][Self::fontColor].
        #[unsafe(method(setFontColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFontColor(&self, font_color: Option<&NSColor>);

        #[cfg(feature = "objc2-core-foundation")]
        /// Controls the blending between the rendered text and a color. The valid interval of values is from 0.0 up to and including 1.0. A value above or below that interval is clamped to the minimum (0.0) if below or the maximum (1.0) if above.
        #[unsafe(method(colorBlendFactor))]
        #[unsafe(method_family = none)]
        pub unsafe fn colorBlendFactor(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
        #[unsafe(method(setColorBlendFactor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);

        /// Color to be blended with the text based on the colorBlendFactor
        #[unsafe(method(color))]
        #[unsafe(method_family = none)]
        pub unsafe fn color(&self) -> Option<Retained<NSColor>>;

        /// Setter for [`color`][Self::color].
        #[unsafe(method(setColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColor(&self, color: Option<&NSColor>);

        /// Sets the blend mode to use when composing the sprite with the final framebuffer.
        ///
        /// See: SKNode.SKBlendMode
        #[unsafe(method(blendMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn blendMode(&self) -> SKBlendMode;

        /// Setter for [`blendMode`][Self::blendMode].
        #[unsafe(method(setBlendMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
    );
}

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

        /// Support coding and decoding via NSKeyedArchiver.
        ///
        /// # 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>>;

        #[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 SKLabelNode {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}