objc2-av-foundation 0.3.2

Bindings to the AVFoundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An `AVCaptureControl` for selecting from a set of mutually exclusive values by index.
    ///
    ///
    /// `AVCaptureIndexPicker` is ideal when the set of values is provided by an indexed container like `NSArray`, `Array`, or `Sequence`. Controls may be added to an `AVCaptureSession` using `-[AVCaptureSession addControl:]`.
    ///
    /// `AVCaptureIndexPicker` uses zero-based indexing.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureindexpicker?language=objc)
    #[unsafe(super(AVCaptureControl, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVCaptureControl")]
    pub struct AVCaptureIndexPicker;
);

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

#[cfg(feature = "AVCaptureControl")]
impl AVCaptureIndexPicker {
    extern_methods!(
        /// Initializes an `AVCaptureIndexPicker` to pick between `numberOfIndexes` values.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the picker.
        ///
        /// Parameter `numberOfIndexes`: The number of indexes to pick between. `numberOfIndexes` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Returns: An `AVCaptureIndexPicker` instance that picks between `numberOfIndexes` values.
        ///
        ///
        /// Suitable when your picked values don't need titles.
        #[unsafe(method(initWithLocalizedTitle:symbolName:numberOfIndexes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_numberOfIndexes(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            number_of_indexes: NSInteger,
        ) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// Initializes an `AVCaptureIndexPicker` to pick between `numberOfIndexes` values.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the picker.
        ///
        /// Parameter `numberOfIndexes`: The number of indexes to pick between. `numberOfIndexes` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Parameter `localizedTitleTransform`: A transformation from index to localized title.
        ///
        /// Returns: An `AVCaptureIndexPicker` instance that picks between `numberOfIndexes` values with a transformation from index to localized title.
        ///
        ///
        /// Suitable when you want to provide a title for each picked value lazily.
        ///
        /// # Safety
        ///
        /// `localized_title_transform` block's return must be a valid pointer.
        #[unsafe(method(initWithLocalizedTitle:symbolName:numberOfIndexes:localizedTitleTransform:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_numberOfIndexes_localizedTitleTransform(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            number_of_indexes: NSInteger,
            localized_title_transform: &block2::DynBlock<
                dyn Fn(NSInteger) -> NonNull<NSString> + '_,
            >,
        ) -> Retained<Self>;

        /// Initializes an `AVCaptureIndexPicker` to pick between `localizedIndexTitles.count` values.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the picker.
        ///
        /// Parameter `localizedIndexTitles`: The titles to use for each index. `localizedIndexTitles` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Returns: An `AVCaptureIndexPicker` instance that picks between `localizedIndexTitles.count` values.
        ///
        ///
        /// Suitable when you already have an array containing a title for each picked value.
        #[unsafe(method(initWithLocalizedTitle:symbolName:localizedIndexTitles:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_localizedIndexTitles(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            localized_index_titles: &NSArray<NSString>,
        ) -> Retained<Self>;

        /// The currently selected index.
        ///
        ///
        /// Because the camera system may be independent from the main thread or `
        /// MainThreadOnly`, `selectedIndex` must be changed on `actionQueue` – the queue provided to `setActionQueue:action:`. The default value is 0. An index may only be set if it is greater than 0 or less than `numberOfIndexes`, otherwise an `NSInvalidArgumentException` is thrown.
        #[unsafe(method(selectedIndex))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedIndex(&self) -> NSInteger;

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

        /// A localized string that describes the picker's `action`.
        #[unsafe(method(localizedTitle))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedTitle(&self) -> Retained<NSString>;

        /// The name of a symbol to represent the picker.
        #[unsafe(method(symbolName))]
        #[unsafe(method_family = none)]
        pub unsafe fn symbolName(&self) -> Retained<NSString>;

        /// The number of indexes to pick between.
        #[unsafe(method(numberOfIndexes))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfIndexes(&self) -> NSInteger;

        /// The titles used for each index.
        #[unsafe(method(localizedIndexTitles))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedIndexTitles(&self) -> Retained<NSArray<NSString>>;

        /// A string that identifies the picker.
        #[unsafe(method(accessibilityIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn accessibilityIdentifier(&self) -> Option<Retained<NSString>>;

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

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// Configures the picker's `action` which is called on `actionQueue` whenever the index of the picker is changed.
        ///
        ///
        /// Parameter `actionQueue`: A queue for the `action` to be called.
        ///
        /// Parameter `action`: An action called on `actionQueue` whenever the selected index of the picker is changed.
        ///
        ///
        /// Because the camera system may be independent from the main thread or `
        /// MainThreadOnly`, `action` is always called on an internal `DispatchSerialQueue` targeted at `actionQueue`.
        ///
        /// If `action` modifies a property of the camera system, `actionQueue` must represent the same exclusive execution context as the camera system (see `isSameExclusiveExecutionContext`).
        ///
        /// # Safety
        ///
        /// `action_queue` possibly has additional threading requirements.
        #[unsafe(method(setActionQueue:action:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActionQueue_action(
            &self,
            action_queue: &DispatchQueue,
            action: &block2::DynBlock<dyn Fn(NSInteger)>,
        );
    );
}

/// Methods declared on superclass `AVCaptureControl`.
#[cfg(feature = "AVCaptureControl")]
impl AVCaptureIndexPicker {
    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>;
    );
}