objc2-ui-kit 0.3.2

Bindings to the UIKit 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::*;
#[cfg(feature = "objc2-cloud-kit")]
use objc2_cloud_kit::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscene?language=objc)
    #[unsafe(super(UIScene, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIScene"))]
    pub struct UIWindowScene;
);

#[cfg(all(feature = "UIResponder", feature = "UIScene"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UIWindowScene {}
);

#[cfg(all(feature = "UIResponder", feature = "UIScene"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UIWindowScene {}
);

#[cfg(all(feature = "UIResponder", feature = "UIScene"))]
impl UIWindowScene {
    extern_methods!(
        #[cfg(feature = "UIScreen")]
        #[unsafe(method(screen))]
        #[unsafe(method_family = none)]
        pub fn screen(&self) -> Retained<UIScreen>;

        #[cfg(feature = "UIOrientation")]
        #[deprecated = "Use effectiveGeometry.interfaceOrientation instead."]
        #[unsafe(method(interfaceOrientation))]
        #[unsafe(method_family = none)]
        pub fn interfaceOrientation(&self) -> UIInterfaceOrientation;

        #[cfg(feature = "UIView")]
        #[deprecated = "Use effectiveGeometry.coordinateSpace instead."]
        #[unsafe(method(coordinateSpace))]
        #[unsafe(method_family = none)]
        pub fn coordinateSpace(&self) -> Retained<ProtocolObject<dyn UICoordinateSpace>>;

        #[cfg(feature = "UITraitCollection")]
        #[unsafe(method(traitCollection))]
        #[unsafe(method_family = none)]
        pub fn traitCollection(&self) -> Retained<UITraitCollection>;

        #[cfg(all(feature = "UIWindowSceneGeometryPreferences", feature = "block2"))]
        #[unsafe(method(requestGeometryUpdateWithPreferences:errorHandler:))]
        #[unsafe(method_family = none)]
        pub fn requestGeometryUpdateWithPreferences_errorHandler(
            &self,
            geometry_preferences: &UIWindowSceneGeometryPreferences,
            error_handler: Option<&block2::DynBlock<dyn Fn(NonNull<NSError>)>>,
        );

        #[cfg(feature = "UIWindowSceneGeometry")]
        #[unsafe(method(effectiveGeometry))]
        #[unsafe(method_family = none)]
        pub fn effectiveGeometry(&self) -> Retained<UIWindowSceneGeometry>;

        #[cfg(feature = "UISceneSizeRestrictions")]
        /// Preferences the system should evaluate when resizing the scene. If non `nil`, returns a mutable instance that the client may customize.
        /// - Note: This property will be `nil` on platforms that don't support scene resizing.
        #[unsafe(method(sizeRestrictions))]
        #[unsafe(method_family = none)]
        pub fn sizeRestrictions(&self) -> Option<Retained<UISceneSizeRestrictions>>;

        #[cfg(all(feature = "UIView", feature = "UIWindow"))]
        #[unsafe(method(windows))]
        #[unsafe(method_family = none)]
        pub fn windows(&self) -> Retained<NSArray<UIWindow>>;

        #[cfg(all(feature = "UIView", feature = "UIWindow"))]
        #[unsafe(method(keyWindow))]
        #[unsafe(method_family = none)]
        pub fn keyWindow(&self) -> Option<Retained<UIWindow>>;

        #[cfg(feature = "UIActivityItemsConfigurationReading")]
        /// An optional object used as a source of scene-level activity items configuration
        ///
        /// If this property returns
        /// `nil,`the
        /// `activityItemsConfiguration`property of the most-presented view controller
        /// of the scene's key window will be used for scene-level sharing and activities.
        #[unsafe(method(activityItemsConfigurationSource))]
        #[unsafe(method_family = none)]
        pub fn activityItemsConfigurationSource(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIActivityItemsConfigurationProviding>>>;

        #[cfg(feature = "UIActivityItemsConfigurationReading")]
        /// Setter for [`activityItemsConfigurationSource`][Self::activityItemsConfigurationSource].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setActivityItemsConfigurationSource:))]
        #[unsafe(method_family = none)]
        pub fn setActivityItemsConfigurationSource(
            &self,
            activity_items_configuration_source: Option<
                &ProtocolObject<dyn UIActivityItemsConfigurationProviding>,
            >,
        );

        #[cfg(feature = "UISceneWindowingBehaviors")]
        /// Additional window behaviors which may be platform specific. This property will be nil on unsupported platforms, otherwise will provide a mutable object for window behavior customization.
        #[unsafe(method(windowingBehaviors))]
        #[unsafe(method_family = none)]
        pub fn windowingBehaviors(&self) -> Option<Retained<UISceneWindowingBehaviors>>;

        #[unsafe(method(isFullScreen))]
        #[unsafe(method_family = none)]
        pub fn isFullScreen(&self) -> bool;
    );
}

/// Methods declared on superclass `UIScene`.
#[cfg(all(feature = "UIResponder", feature = "UIScene"))]
impl UIWindowScene {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(feature = "UISceneOptions", feature = "UISceneSession"))]
        #[unsafe(method(initWithSession:connectionOptions:))]
        #[unsafe(method_family = init)]
        pub fn initWithSession_connectionOptions(
            this: Allocated<Self>,
            session: &UISceneSession,
            connection_options: &UISceneConnectionOptions,
        ) -> Retained<Self>;
    );
}

#[cfg(all(feature = "UIResponder", feature = "UIScene"))]
impl UIWindowScene {
    extern_methods!(
        #[cfg(feature = "UITraitCollection")]
        #[unsafe(method(traitOverrides))]
        #[unsafe(method_family = none)]
        pub fn traitOverrides(&self) -> Retained<ProtocolObject<dyn UITraitOverrides>>;
    );
}

#[cfg(all(
    feature = "UIResponder",
    feature = "UIScene",
    feature = "UITraitCollection"
))]
extern_conformance!(
    unsafe impl UITraitChangeObservable for UIWindowScene {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UIScene",
    feature = "UITraitCollection"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UIWindowScene {}
);

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenedelegate?language=objc)
    #[cfg(feature = "UIScene")]
    pub unsafe trait UIWindowSceneDelegate: UISceneDelegate + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "UIWindow"))]
        #[optional]
        #[unsafe(method(window))]
        #[unsafe(method_family = none)]
        fn window(&self) -> Option<Retained<UIWindow>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "UIWindow"))]
        /// Setter for [`window`][Self::window].
        #[optional]
        #[unsafe(method(setWindow:))]
        #[unsafe(method_family = none)]
        fn setWindow(&self, window: Option<&UIWindow>);

        #[cfg(all(
            feature = "UIOrientation",
            feature = "UIResponder",
            feature = "UITraitCollection",
            feature = "UIView"
        ))]
        /// Called when the coordinate space, interface orientation, or trait collection of a `UIWindowScene` changes.
        ///
        /// Always called when a UIWindowScene moves between screens.
        #[deprecated = "Use windowScene(_: didUpdateEffectiveGeometry:) to be notified of the scene's geometry changes, or use traits whose values are inherited from the scene via the traitCollection of views and view controllers instead."]
        #[optional]
        #[unsafe(method(windowScene:didUpdateCoordinateSpace:interfaceOrientation:traitCollection:))]
        #[unsafe(method_family = none)]
        fn windowScene_didUpdateCoordinateSpace_interfaceOrientation_traitCollection(
            &self,
            window_scene: &UIWindowScene,
            previous_coordinate_space: &ProtocolObject<dyn UICoordinateSpace>,
            previous_interface_orientation: UIInterfaceOrientation,
            previous_trait_collection: &UITraitCollection,
        );

        #[cfg(all(feature = "UIResponder", feature = "UIWindowSceneGeometry"))]
        /// Called when the window scene's effective geometry has changed.
        ///
        /// Always called when a `UIWindowScene` moves between screens.
        #[optional]
        #[unsafe(method(windowScene:didUpdateEffectiveGeometry:))]
        #[unsafe(method_family = none)]
        fn windowScene_didUpdateEffectiveGeometry(
            &self,
            window_scene: &UIWindowScene,
            previous_effective_geometry: &UIWindowSceneGeometry,
        );

        #[cfg(all(
            feature = "UIApplicationShortcutItem",
            feature = "UIResponder",
            feature = "block2"
        ))]
        #[optional]
        #[unsafe(method(windowScene:performActionForShortcutItem:completionHandler:))]
        #[unsafe(method_family = none)]
        fn windowScene_performActionForShortcutItem_completionHandler(
            &self,
            window_scene: &UIWindowScene,
            shortcut_item: &UIApplicationShortcutItem,
            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
        );

        #[cfg(all(feature = "UIResponder", feature = "objc2-cloud-kit"))]
        #[optional]
        #[unsafe(method(windowScene:userDidAcceptCloudKitShareWithMetadata:))]
        #[unsafe(method_family = none)]
        fn windowScene_userDidAcceptCloudKitShareWithMetadata(
            &self,
            window_scene: &UIWindowScene,
            cloud_kit_share_metadata: &CKShareMetadata,
        );

        #[cfg(all(feature = "UIResponder", feature = "UISceneWindowingControlStyle"))]
        /// Called by the system to determine the windowing control style for the provided scene.
        /// `automaticStyle` will be used if this method is not implemented.
        #[optional]
        #[unsafe(method(preferredWindowingControlStyleForScene:))]
        #[unsafe(method_family = none)]
        fn preferredWindowingControlStyleForScene(
            &self,
            window_scene: &UIWindowScene,
        ) -> Retained<UISceneWindowingControlStyle>;
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenesessionroleapplication?language=objc)
    #[cfg(feature = "UISceneDefinitions")]
    pub static UIWindowSceneSessionRoleApplication: &'static UISceneSessionRole;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenesessionroleexternaldisplaynoninteractive?language=objc)
    #[cfg(feature = "UISceneDefinitions")]
    pub static UIWindowSceneSessionRoleExternalDisplayNonInteractive: &'static UISceneSessionRole;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenesessionroleexternaldisplay?language=objc)
    #[cfg(feature = "UISceneDefinitions")]
    #[deprecated]
    pub static UIWindowSceneSessionRoleExternalDisplay: &'static UISceneSessionRole;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenesessionrolevolumetricapplication?language=objc)
    #[cfg(feature = "UISceneDefinitions")]
    pub static UIWindowSceneSessionRoleVolumetricApplication: &'static UISceneSessionRole;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenesessionroleassistiveaccessapplication?language=objc)
    #[cfg(feature = "UISceneDefinitions")]
    pub static UIWindowSceneSessionRoleAssistiveAccessApplication: &'static UISceneSessionRole;
}

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiwindowscenedismissalanimation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIWindowSceneDismissalAnimation(pub NSInteger);
impl UIWindowSceneDismissalAnimation {
    #[doc(alias = "UIWindowSceneDismissalAnimationStandard")]
    pub const Standard: Self = Self(1);
    #[doc(alias = "UIWindowSceneDismissalAnimationCommit")]
    pub const Commit: Self = Self(2);
    #[doc(alias = "UIWindowSceneDismissalAnimationDecline")]
    pub const Decline: Self = Self(3);
}

unsafe impl Encode for UIWindowSceneDismissalAnimation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

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

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

#[cfg(feature = "UISceneOptions")]
impl UIWindowSceneDestructionRequestOptions {
    extern_methods!(
        #[unsafe(method(windowDismissalAnimation))]
        #[unsafe(method_family = none)]
        pub fn windowDismissalAnimation(&self) -> UIWindowSceneDismissalAnimation;

        /// Setter for [`windowDismissalAnimation`][Self::windowDismissalAnimation].
        #[unsafe(method(setWindowDismissalAnimation:))]
        #[unsafe(method_family = none)]
        pub fn setWindowDismissalAnimation(
            &self,
            window_dismissal_animation: UIWindowSceneDismissalAnimation,
        );
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UISceneOptions")]
impl UIWindowSceneDestructionRequestOptions {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}