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 a value from a bounded range of values.
    ///
    ///
    /// `AVCaptureSlider` is ideal when your control only needs a single float value. Controls may be added to an `AVCaptureSession` using `-[AVCaptureSession addControl:]`.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureslider?language=objc)
    #[unsafe(super(AVCaptureControl, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "AVCaptureControl")]
    pub struct AVCaptureSlider;
);

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

#[cfg(feature = "AVCaptureControl")]
impl AVCaptureSlider {
    extern_methods!(
        /// Initializes an `AVCaptureSlider` as a continuous slider between `minValue` and `maxValue`.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the slider's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the slider.
        ///
        /// Parameter `minValue`: The minimum value the slider can have. `minValue` must be less than `maxValue`, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Parameter `maxValue`: The maximum value the slider can have. `maxValue` must be greater than `minValue`, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Returns: An `AVCaptureSlider` instance as a continuous slider between `minValue` and `maxValue`.
        ///
        ///
        /// Continuous sliders are used when any value in the range `minValue...maxValue` is supported.
        #[unsafe(method(initWithLocalizedTitle:symbolName:minValue:maxValue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_minValue_maxValue(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            min_value: c_float,
            max_value: c_float,
        ) -> Retained<Self>;

        /// Initializes an `AVCaptureSlider` as a discrete slider where the valid values are between `minValue` and `maxValue` with `step` distance between each value.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the slider's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the slider.
        ///
        /// Parameter `minValue`: The minimum value the slider can have. `minValue` must be less than `maxValue`, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Parameter `maxValue`: The maximum value the slider can have. `maxValue` must be greater than `minValue`, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Parameter `step`: The distance between each valid value. `step` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
        ///
        /// Returns: An `AVCaptureSlider` instance as a discrete slider where the valid values are between `minValue` and `maxValue` with `step` distance between each value.
        ///
        ///
        /// Discrete sliders are used when only specific values are valid.
        #[unsafe(method(initWithLocalizedTitle:symbolName:minValue:maxValue:step:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_minValue_maxValue_step(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            min_value: c_float,
            max_value: c_float,
            step: c_float,
        ) -> Retained<Self>;

        /// Initializes an `AVCaptureSlider` as a discrete slider where `values` contains the valid values.
        ///
        ///
        /// Parameter `localizedTitle`: A localized string that describes the slider's `action`.
        ///
        /// Parameter `symbolName`: The name of a symbol to represent the slider.
        ///
        /// Parameter `values`: The only values the slider can have.
        ///
        /// Returns: An `AVCaptureSlider` instance as a discrete slider where `values` contains the valid values.
        ///
        ///
        /// Discrete sliders are used when only specific values are valid.
        #[unsafe(method(initWithLocalizedTitle:symbolName:values:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithLocalizedTitle_symbolName_values(
            this: Allocated<Self>,
            localized_title: &NSString,
            symbol_name: &NSString,
            values: &NSArray<NSNumber>,
        ) -> Retained<Self>;

        /// The current value of the slider.
        ///
        ///
        /// Because the camera system may be independent from the main thread or `
        /// MainThreadOnly`, `value` must be changed on `actionQueue` – the queue provided to `setActionQueue:action:`. The default value is the slider's minimum value. A value may only be set if it is within the slider's minimum and maximum values, otherwise an `NSInvalidArgumentException` is thrown.
        #[unsafe(method(value))]
        #[unsafe(method_family = none)]
        pub unsafe fn value(&self) -> c_float;

        /// Setter for [`value`][Self::value].
        #[unsafe(method(setValue:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue(&self, value: c_float);

        /// A localized string defining the presentation of the slider's value.
        ///
        ///
        /// To modify the presentation of the slider's value, set `localizedValueFormat` to a format string to display the slider's value with any annotation.
        ///
        /// The format string may only contain `%
        /// @
        /// ` and no other placeholders like `%d`, `%s`, etc. Invalid format strings will result in the value's default presentation.
        ///
        /// Examples of valid format strings are:
        /// - `%
        /// %
        /// %` for "40%"
        /// - `%
        /// @
        /// fps` for "60 fps"
        /// - `+ %
        /// @
        /// ` for "+ 20"
        #[unsafe(method(localizedValueFormat))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedValueFormat(&self) -> Option<Retained<NSString>>;

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

        /// Values in this array may receive unique visual representations or behaviors.
        #[unsafe(method(prominentValues))]
        #[unsafe(method_family = none)]
        pub unsafe fn prominentValues(&self) -> Retained<NSArray<NSNumber>>;

        /// Setter for [`prominentValues`][Self::prominentValues].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setProminentValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setProminentValues(&self, prominent_values: &NSArray<NSNumber>);

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

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

        /// A string that identifies the slider.
        #[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 slider's `action` which is called on `actionQueue` whenever the value of the slider is changed.
        ///
        ///
        /// Parameter `actionQueue`: A queue for the `action` to be called.
        ///
        /// Parameter `action`: An action called on `actionQueue` whenever the value of the slider 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(c_float)>,
        );
    );
}

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