objc2-car-play 0.3.2

Bindings to the CarPlay 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::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingtemplateobserver?language=objc)
    pub unsafe trait CPNowPlayingTemplateObserver: NSObjectProtocol {
        #[cfg(feature = "CPTemplate")]
        /// The user has selected the Up Next button on the now playing template. Your application
        /// should push a new template displaying the list of upcoming or queued content.
        #[optional]
        #[unsafe(method(nowPlayingTemplateUpNextButtonTapped:))]
        #[unsafe(method_family = none)]
        unsafe fn nowPlayingTemplateUpNextButtonTapped(
            &self,
            now_playing_template: &CPNowPlayingTemplate,
        );

        #[cfg(feature = "CPTemplate")]
        /// The user has selected the album/artist button on the now playing template. Your application
        /// should push a new template displaying the content appearing in this container (album, playlist, or show).
        #[optional]
        #[unsafe(method(nowPlayingTemplateAlbumArtistButtonTapped:))]
        #[unsafe(method_family = none)]
        unsafe fn nowPlayingTemplateAlbumArtistButtonTapped(
            &self,
            now_playing_template: &CPNowPlayingTemplate,
        );
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingtemplate?language=objc)
    #[unsafe(super(CPTemplate, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPTemplate")]
    pub struct CPNowPlayingTemplate;
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSCoding for CPNowPlayingTemplate {}
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CPNowPlayingTemplate {}
);

#[cfg(feature = "CPTemplate")]
extern_conformance!(
    unsafe impl NSSecureCoding for CPNowPlayingTemplate {}
);

#[cfg(feature = "CPTemplate")]
impl CPNowPlayingTemplate {
    extern_methods!(
        /// Access the shared now playing template for your app. Instead of creating your own
        /// now playing template, you should configure the properties of this shared instance.
        ///
        /// You should present this shared instance when your app needs to present now playing,
        /// for example in response to the user selecting a playable item.
        ///
        /// When the system needs to present now playing on behalf of your app, it will present
        /// this shared instance.
        #[unsafe(method(sharedTemplate))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedTemplate(mtm: MainThreadMarker) -> Retained<CPNowPlayingTemplate>;

        #[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(mtm: MainThreadMarker) -> Retained<Self>;

        /// Add an observer. Observers are notified about now playing template events.
        #[unsafe(method(addObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver(
            &self,
            observer: &ProtocolObject<dyn CPNowPlayingTemplateObserver>,
        );

        /// Remove an observer.
        #[unsafe(method(removeObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeObserver(
            &self,
            observer: &ProtocolObject<dyn CPNowPlayingTemplateObserver>,
        );

        #[cfg(feature = "CPNowPlayingButton")]
        /// Playback control buttons on the Now Playing screen, like repeat, shuffle, and more.
        ///
        /// Your application may specify a maximum of 5 now playing buttons.
        ///
        ///
        /// Buttons are filled in array order, from the leading side to the trailing side of the screen.
        #[unsafe(method(nowPlayingButtons))]
        #[unsafe(method_family = none)]
        pub unsafe fn nowPlayingButtons(&self) -> Retained<NSArray<CPNowPlayingButton>>;

        /// A Boolean value indicating whether the "Up Next" button on the upper right of a Now Playing view is enabled.
        ///
        ///
        /// Set the value of this property to
        /// `YES`to enable the button.
        ///
        /// Defaults to NO.
        #[unsafe(method(isUpNextButtonEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isUpNextButtonEnabled(&self) -> bool;

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

        /// If your template elects to display the "Up Next" button, you may optionally specify a string
        /// indicating the title for the up next button. If no title is specified, a default system title
        /// will be used.
        ///
        ///
        /// See: -[CPNowPlayingTemplate upNextButtonEnabled].
        #[unsafe(method(upNextTitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn upNextTitle(&self) -> Retained<NSString>;

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

        /// A Boolean value indicating whether the string that displays the album and artist above the playback controls should be a tappable button
        ///
        ///
        /// Set the value of this property to
        /// `YES`to enable the button.
        ///
        /// Defaults to NO.
        #[unsafe(method(isAlbumArtistButtonEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAlbumArtistButtonEnabled(&self) -> bool;

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

        #[cfg(feature = "CPNowPlayingButton")]
        /// Update the buttons displayed in this Now Playing template.
        #[unsafe(method(updateNowPlayingButtons:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateNowPlayingButtons(
            &self,
            now_playing_buttons: &NSArray<CPNowPlayingButton>,
        );

        #[cfg(feature = "CPNowPlayingMode")]
        /// The currently-active now playing mode. See
        /// `CPNowPlayingMode.`
        #[unsafe(method(nowPlayingMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn nowPlayingMode(&self) -> Option<Retained<CPNowPlayingMode>>;

        #[cfg(feature = "CPNowPlayingMode")]
        /// Setter for [`nowPlayingMode`][Self::nowPlayingMode].
        #[unsafe(method(setNowPlayingMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setNowPlayingMode(&self, now_playing_mode: Option<&CPNowPlayingMode>);
    );
}