objc2-screen-capture-kit 0.3.2

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

/// SCContentSharingPickerModeSingleWindow picker mode for single window selection
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickermode?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCContentSharingPickerMode(pub NSUInteger);
bitflags::bitflags! {
    impl SCContentSharingPickerMode: NSUInteger {
        #[doc(alias = "SCContentSharingPickerModeSingleWindow")]
        const SingleWindow = 1<<0;
        #[doc(alias = "SCContentSharingPickerModeMultipleWindows")]
        const MultipleWindows = 1<<1;
        #[doc(alias = "SCContentSharingPickerModeSingleApplication")]
        const SingleApplication = 1<<2;
        #[doc(alias = "SCContentSharingPickerModeMultipleApplications")]
        const MultipleApplications = 1<<3;
        #[doc(alias = "SCContentSharingPickerModeSingleDisplay")]
        const SingleDisplay = 1<<4;
    }
}

unsafe impl Encode for SCContentSharingPickerMode {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    /// SCContentSharingPickerConfiguration
    ///
    /// SCContentSharingPickerConfiguration is an object which can optionally be set on the SCContentSharingPicker for customized configuration.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickerconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCContentSharingPickerConfiguration<NSCopying: ?Sized = AnyObject>;
);

impl<NSCopying: ?Sized + Message> SCContentSharingPickerConfiguration<NSCopying> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewNSCopying: ?Sized + Message>(
        &self,
    ) -> &SCContentSharingPickerConfiguration<NewNSCopying> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

extern_conformance!(
    unsafe impl<NSCopying: ?Sized> NSObjectProtocol for SCContentSharingPickerConfiguration<NSCopying> {}
);

impl<NSCopying: Message> SCContentSharingPickerConfiguration<NSCopying> {
    extern_methods!(
        /// allowedPickerModes Limits the type of selections available to the user when the picker is presented. Default is 0, no excluded picking modes
        #[unsafe(method(allowedPickerModes))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowedPickerModes(&self) -> SCContentSharingPickerMode;

        /// Setter for [`allowedPickerModes`][Self::allowedPickerModes].
        #[unsafe(method(setAllowedPickerModes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAllowedPickerModes(
            &self,
            allowed_picker_modes: SCContentSharingPickerMode,
        );

        /// excludedWindowIDs Excludes CGWindowIDs for picking
        #[unsafe(method(excludedWindowIDs))]
        #[unsafe(method_family = none)]
        pub unsafe fn excludedWindowIDs(&self) -> Retained<NSArray<NSNumber>>;

        /// Setter for [`excludedWindowIDs`][Self::excludedWindowIDs].
        #[unsafe(method(setExcludedWindowIDs:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExcludedWindowIDs(&self, excluded_window_i_ds: &NSArray<NSNumber>);

        /// excludedBundleIDs Excludes bundle IDs for picking
        #[unsafe(method(excludedBundleIDs))]
        #[unsafe(method_family = none)]
        pub unsafe fn excludedBundleIDs(&self) -> Retained<NSArray<NSString>>;

        /// Setter for [`excludedBundleIDs`][Self::excludedBundleIDs].
        #[unsafe(method(setExcludedBundleIDs:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setExcludedBundleIDs(&self, excluded_bundle_i_ds: &NSArray<NSString>);

        /// allowsChangingSelectedContent Controls if the user can make updates to the content filter after the initial selection. Defaults is YES.
        #[unsafe(method(allowsChangingSelectedContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowsChangingSelectedContent(&self) -> bool;

        /// Setter for [`allowsChangingSelectedContent`][Self::allowsChangingSelectedContent].
        #[unsafe(method(setAllowsChangingSelectedContent:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAllowsChangingSelectedContent(
            &self,
            allows_changing_selected_content: bool,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl<NSCopying: Message> SCContentSharingPickerConfiguration<NSCopying> {
    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>;
    );
}

extern_class!(
    /// SCContentSharingPicker
    ///
    /// SCContentSharingPicker is an object created by client applications to opt-in to Control Center's content picker
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpicker?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCContentSharingPicker;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for SCContentSharingPicker {}
);

impl SCContentSharingPicker {
    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>;

        /// sharedPicker the singleton shared picker for the application
        #[unsafe(method(sharedPicker))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedPicker() -> Retained<SCContentSharingPicker>;

        /// defaultConfiguration for the content sharing picker. If a stream does not have a configuration, the default configuration will be used.
        #[unsafe(method(defaultConfiguration))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultConfiguration(&self) -> Retained<SCContentSharingPickerConfiguration>;

        /// Setter for [`defaultConfiguration`][Self::defaultConfiguration].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `default_configuration` generic should be of the correct type.
        #[unsafe(method(setDefaultConfiguration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultConfiguration(
            &self,
            default_configuration: &SCContentSharingPickerConfiguration,
        );

        /// maximumStreamCount An integer value that, if set, limits when Control Center will show the UI to present a picker with no associated stream. If set to 0, Control Center will never ever show UI to present a picker without an associated stream.
        #[unsafe(method(maximumStreamCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumStreamCount(&self) -> Option<Retained<NSNumber>>;

        /// Setter for [`maximumStreamCount`][Self::maximumStreamCount].
        #[unsafe(method(setMaximumStreamCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMaximumStreamCount(&self, maximum_stream_count: Option<&NSNumber>);

        /// active A picker needs to be marked as active for its UI to appear. If `startPickingContent` is called and the picker is not marked as active, the picker will not appear.
        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isActive(&self) -> bool;

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

        /// addObserver:
        ///
        /// Parameter `observer`: the observer object that adheres to SCContentSharingPickerObserver protocol
        ///
        /// Adds an observer object that will receive the results of user interaction with a displayed picker
        #[unsafe(method(addObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addObserver(
            &self,
            observer: &ProtocolObject<dyn SCContentSharingPickerObserver>,
        );

        /// removeObserver:
        ///
        /// Parameter `observer`: the observer object that adheres to SCContentSharingPickerObserver protocol
        ///
        /// Removes an observer object that will receive the results of user interaction with a displayed picker
        #[unsafe(method(removeObserver:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeObserver(
            &self,
            observer: &ProtocolObject<dyn SCContentSharingPickerObserver>,
        );

        #[cfg(feature = "SCStream")]
        /// setConfiguration:forStream:
        ///
        /// Parameter `pickerConfig`: configuration for the picker
        ///
        /// Parameter `stream`: stream for optional picking configuration
        ///
        /// Sets optional configuration for the picker for a specific stream. If this is not set, the stream will use the defaultConfiguration instead
        ///
        /// # Safety
        ///
        /// `picker_config` generic should be of the correct type.
        #[unsafe(method(setConfiguration:forStream:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConfiguration_forStream(
            &self,
            picker_config: Option<&SCContentSharingPickerConfiguration>,
            stream: &SCStream,
        );

        /// present
        ///
        /// show content sharing picker to get content for updating a new stream
        #[unsafe(method(present))]
        #[unsafe(method_family = none)]
        pub unsafe fn present(&self);

        #[cfg(feature = "SCShareableContent")]
        /// presentPickerUsingContentStyle:
        ///
        /// Parameter `contentStyle`: the mode in which picking should start
        ///
        /// Takes a person straight into picking particular windows or displays
        #[unsafe(method(presentPickerUsingContentStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentPickerUsingContentStyle(&self, content_style: SCShareableContentStyle);

        #[cfg(feature = "SCStream")]
        /// presentPickerForStream:
        ///
        /// Parameter `stream`: the stream to update
        ///
        /// show content sharing picker with an existing stream
        #[unsafe(method(presentPickerForStream:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentPickerForStream(&self, stream: &SCStream);

        #[cfg(all(feature = "SCShareableContent", feature = "SCStream"))]
        /// presentPickerForStream:usingContentStyle:
        ///
        /// Parameter `stream`: the stream that the picker will display
        ///
        /// Parameter `contentStyle`: the mode in which picking should start
        ///
        /// Takes a person straight into picking particular windows or displays
        #[unsafe(method(presentPickerForStream:usingContentStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentPickerForStream_usingContentStyle(
            &self,
            stream: &SCStream,
            content_style: SCShareableContentStyle,
        );
    );
}

extern_protocol!(
    /// SCContentSharingPickerObserver
    ///
    /// SCContentSharingPickerObserver the protocol that is used to inform client when the picker did make selection or cancel
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickerobserver?language=objc)
    pub unsafe trait SCContentSharingPickerObserver: NSObjectProtocol {
        #[cfg(feature = "SCStream")]
        /// contentSharingPicker:didCancelforStream:
        ///
        /// Parameter `picker`: the SCContentSharingPicker object
        ///
        /// Parameter `stream`: the optional associated stream for this picker
        ///
        /// the observer callback method when the picker has been canceled with no selection.
        #[unsafe(method(contentSharingPicker:didCancelForStream:))]
        #[unsafe(method_family = none)]
        unsafe fn contentSharingPicker_didCancelForStream(
            &self,
            picker: &SCContentSharingPicker,
            stream: Option<&SCStream>,
        );

        #[cfg(feature = "SCStream")]
        /// contentSharingPicker:didUpdateWithFilter:forStream:
        ///
        /// Parameter `picker`: the SCContentSharingPicker object
        ///
        /// Parameter `filter`: the updated filter
        ///
        /// Parameter `stream`: the updated stream
        ///
        /// the observer callback method when the user has finished updating content for a stream
        #[unsafe(method(contentSharingPicker:didUpdateWithFilter:forStream:))]
        #[unsafe(method_family = none)]
        unsafe fn contentSharingPicker_didUpdateWithFilter_forStream(
            &self,
            picker: &SCContentSharingPicker,
            filter: &SCContentFilter,
            stream: Option<&SCStream>,
        );

        /// contentSharingPickerStartDidFailWithError:
        ///
        /// Parameter `error`: the error denoted for the failure to start picker
        ///
        /// the observer callback method when the picker was asked to start but failed to do so.
        #[unsafe(method(contentSharingPickerStartDidFailWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn contentSharingPickerStartDidFailWithError(&self, error: &NSError);
    }
);