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_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cptabbartemplate?language=objc)
    #[unsafe(super(CPTemplate, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CPTemplate")]
    pub struct CPTabBarTemplate;
);

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

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

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

#[cfg(feature = "CPTemplate")]
impl CPTabBarTemplate {
    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(mtm: MainThreadMarker) -> Retained<Self>;

        /// Initialize the tab bar with an array of templates. Each template in the array
        /// becomes a tab on the tab bar.
        ///
        /// The maximum number of tabs in the tab bar template is given by
        /// `maximumTabCount.`
        #[unsafe(method(initWithTemplates:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTemplates(
            this: Allocated<Self>,
            templates: &NSArray<CPTemplate>,
        ) -> Retained<Self>;

        /// The tab bar delegate is informed of tab bar events, like selecting a tab.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn CPTabBarTemplateDelegate>>>;

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

        /// The maximum number of tabs that your app may display in a
        /// `CPTabBarTemplate,`depending on the entitlements that your app declares.
        ///
        ///
        /// Warning: The system will throw an exception if your app attempts to display more
        /// than this number of tabs in your tab bar template.
        #[unsafe(method(maximumTabCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumTabCount(mtm: MainThreadMarker) -> NSInteger;

        /// The currently-visible templates in the tab bar. Each template corresponds to
        /// a single tab on the tab bar.
        #[unsafe(method(templates))]
        #[unsafe(method_family = none)]
        pub unsafe fn templates(&self) -> Retained<NSArray<CPTemplate>>;

        /// The currently-selected template in the tab bar.
        #[unsafe(method(selectedTemplate))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedTemplate(&self) -> Option<Retained<CPTemplate>>;

        /// Update the tabs displayed in this tab bar, replacing the currently-visible tabs.
        /// Each template in the array becomes a tab on the tab bar.
        #[unsafe(method(updateTemplates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateTemplates(&self, new_templates: &NSArray<CPTemplate>);

        /// Update the currently-selected tab in this tab bar template, switching to the first tab
        /// that is currently hosting
        /// `newTemplate.`
        /// Parameter `newTemplate`: The template that should become selected in the tab bar.
        #[unsafe(method(selectTemplate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectTemplate(&self, new_template: &CPTemplate);

        /// Update the currently-selected tab in this tab bar template, switching to the tab
        /// at the specified index.
        ///
        ///
        /// Parameter `index`: The index of the tab to select. This must be less than the number
        /// of tabs in this tab bar template.
        #[unsafe(method(selectTemplateAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectTemplateAtIndex(&self, index: NSInteger);
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cptabbartemplatedelegate?language=objc)
    pub unsafe trait CPTabBarTemplateDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(feature = "CPTemplate")]
        /// The user has selected one of the tabs in the tab bar template, bringing the selected template to the foreground.
        #[unsafe(method(tabBarTemplate:didSelectTemplate:))]
        #[unsafe(method_family = none)]
        unsafe fn tabBarTemplate_didSelectTemplate(
            &self,
            tab_bar_template: &CPTabBarTemplate,
            selected_template: &CPTemplate,
        );
    }
);