objc2-tv-services 0.3.2

Bindings to the TVServices 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::*;
use objc2_foundation::*;

use crate::*;

/// The shape of an image in the sectioned content style.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfsectioneditemimageshape?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct TVTopShelfSectionedItemImageShape(pub NSInteger);
impl TVTopShelfSectionedItemImageShape {
    /// A 1:1 image.
    #[doc(alias = "TVTopShelfSectionedItemImageShapeSquare")]
    pub const Square: Self = Self(0);
    /// A 2:3 poster image.
    #[doc(alias = "TVTopShelfSectionedItemImageShapePoster")]
    pub const Poster: Self = Self(1);
    /// A 16:9 image.
    #[doc(alias = "TVTopShelfSectionedItemImageShapeHDTV")]
    pub const HDTV: Self = Self(2);
}

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

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

extern_class!(
    /// An object that represents a single item in the sectioned content style.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/tvservices/tvtopshelfsectioneditem?language=objc)
    #[unsafe(super(TVTopShelfItem, TVTopShelfObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
    pub struct TVTopShelfSectionedItem;
);

#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for TVTopShelfSectionedItem {}
);

#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl TVTopShelfSectionedItem {
    extern_methods!(
        /// The shape of the item's image.
        ///
        /// The default value is `.square`.
        #[unsafe(method(imageShape))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageShape(&self) -> TVTopShelfSectionedItemImageShape;

        /// Setter for [`imageShape`][Self::imageShape].
        #[unsafe(method(setImageShape:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImageShape(&self, image_shape: TVTopShelfSectionedItemImageShape);

        /// How far into the item the user has played.
        ///
        /// Must be a number in the range `0...1`.
        #[unsafe(method(playbackProgress))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackProgress(&self) -> c_double;

        /// Setter for [`playbackProgress`][Self::playbackProgress].
        #[unsafe(method(setPlaybackProgress:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPlaybackProgress(&self, playback_progress: c_double);
    );
}

/// Methods declared on superclass `TVTopShelfItem`.
#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl TVTopShelfSectionedItem {
    extern_methods!(
        /// Create an item with a unique identifier.
        ///
        /// This identifier must be unique in the set of items you return to the system.
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithIdentifier(
            this: Allocated<Self>,
            identifier: &NSString,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `TVTopShelfObject`.
#[cfg(all(feature = "TVTopShelfItem", feature = "TVTopShelfObject"))]
impl TVTopShelfSectionedItem {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}