objc2-ar-kit 0.3.2

Bindings to the ARKit 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 = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
use objc2_quartz_core::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// A value describing the context required for successful coaching
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/arkit/arcoachinggoal?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ARCoachingGoal(pub NSInteger);
#[cfg(feature = "objc2")]
impl ARCoachingGoal {
    /// Session requires normal tracking
    #[doc(alias = "ARCoachingGoalTracking")]
    pub const Tracking: Self = Self(0);
    /// Session requires a horizontal plane
    #[doc(alias = "ARCoachingGoalHorizontalPlane")]
    pub const HorizontalPlane: Self = Self(1);
    /// Session requires a vertical plane
    #[doc(alias = "ARCoachingGoalVerticalPlane")]
    pub const VerticalPlane: Self = Self(2);
    /// Session requires one plane of any type
    #[doc(alias = "ARCoachingGoalAnyPlane")]
    pub const AnyPlane: Self = Self(3);
    /// Session requires geo tracking
    #[doc(alias = "ARCoachingGoalGeoTracking")]
    pub const GeoTracking: Self = Self(4);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for ARCoachingGoal {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for ARCoachingGoal {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "objc2")]
extern_class!(
    /// A view that guides users through session initialization
    ///
    ///
    /// The view will use context aware messaging and animations to instruct the user on gathering required info for the AR session.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/arkit/arcoachingoverlayview?language=objc)
    #[unsafe(super(UIView, UIResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
    pub struct ARCoachingOverlayView;
);

#[cfg(all(
    feature = "objc2",
    feature = "objc2-quartz-core",
    feature = "objc2-ui-kit"
))]
extern_conformance!(
    unsafe impl CALayerDelegate for ARCoachingOverlayView {}
);

#[cfg(all(
    feature = "objc2",
    feature = "objc2-foundation",
    feature = "objc2-ui-kit"
))]
extern_conformance!(
    unsafe impl NSCoding for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIAppearance for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UICoordinateSpace for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIDynamicItem for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIFocusItem for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIFocusItemContainer for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
extern_conformance!(
    unsafe impl UITraitEnvironment for ARCoachingOverlayView {}
);

#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
impl ARCoachingOverlayView {
    extern_methods!(
        /// Specifies the delegate used for callbacks
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn ARCoachingOverlayViewDelegate>>>;

        /// 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 ARCoachingOverlayViewDelegate>>,
        );

        #[cfg(feature = "ARSession")]
        /// A provider of a session to use
        ///
        ///
        /// This property can be used to set the `session` when loading from a storyboard. Setting this property at runtime will also
        /// set the `session` property.
        #[unsafe(method(sessionProvider))]
        #[unsafe(method_family = none)]
        pub unsafe fn sessionProvider(&self) -> Option<Retained<NSObject>>;

        #[cfg(feature = "ARSession")]
        /// Setter for [`sessionProvider`][Self::sessionProvider].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `session_provider` must implement ARSessionProviding.
        #[unsafe(method(setSessionProvider:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSessionProvider(&self, session_provider: Option<&NSObject>);

        #[cfg(feature = "ARSession")]
        /// The session that the view uses to update coaching
        #[unsafe(method(session))]
        #[unsafe(method_family = none)]
        pub unsafe fn session(&self) -> Option<Retained<ARSession>>;

        #[cfg(feature = "ARSession")]
        /// Setter for [`session`][Self::session].
        #[unsafe(method(setSession:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSession(&self, session: Option<&ARSession>);

        /// The coaching type used to resolve what messaging to display to the user while activated
        /// Defaults to `ARCoachingGoalTracking`
        #[unsafe(method(goal))]
        #[unsafe(method_family = none)]
        pub unsafe fn goal(&self) -> ARCoachingGoal;

        /// Setter for [`goal`][Self::goal].
        #[unsafe(method(setGoal:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGoal(&self, goal: ARCoachingGoal);

        /// Whether or not the view should activate/deactivate automatically, depending on the current state of the session
        /// Defaults to `YES`
        ///
        ///
        /// When set to automatically activate, the view will transition to active when the session loses normal tracking for a set amount
        /// of time.
        /// When tracking resumes and other requirements (based on `goal`) are met, the view will deactivate.
        #[unsafe(method(activatesAutomatically))]
        #[unsafe(method_family = none)]
        pub unsafe fn activatesAutomatically(&self) -> bool;

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

        /// Whether or not the view is currently active.
        ///
        ///
        /// See: -[ARCoachingOverlayView setActive:animated:]
        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isActive(&self) -> bool;

        /// Transition the view to either an activated or deactivated state
        ///
        ///
        /// On activation the view will check the current session, and if relocalization is needed it will present a modified UI with
        /// relocalization coaching and a reset button.
        ///
        /// On deactivation the view will become hidden
        ///
        /// Parameter `active`: Whether the view should activate, or deactivate
        ///
        /// Parameter `animated`: Whether the view animated to activated/deactivated states, or transitions instantly
        ///
        ///
        /// See: -[ARCoachingOverlayViewDelegate coachingOverlayViewDidTriggerReset:]
        #[unsafe(method(setActive:animated:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActive_animated(&self, active: bool, animated: bool);
    );
}

/// Methods declared on superclass `UIView`.
#[cfg(all(feature = "objc2", feature = "objc2-ui-kit"))]
impl ARCoachingOverlayView {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;

        #[cfg(feature = "objc2-foundation")]
        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

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

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

#[cfg(feature = "objc2")]
extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/arkit/arcoachingoverlayviewdelegate?language=objc)
    #[cfg(feature = "objc2")]
    pub unsafe trait ARCoachingOverlayViewDelegate: NSObjectProtocol {
        #[cfg(feature = "objc2-ui-kit")]
        /// This is called when the user taps the reset button in the relocalization state
        ///
        ///
        /// By default, when the relocalization reset button is tapped, the overlay will call run on the session using the current
        /// `configuration`, and the `ARSessionRunOptionResetTracking` and `ARSessionRunOptionRemoveExistingAnchors` options. The delegate may
        /// implement this method to override this behavior. The delegate is then responsible for resetting the session.
        ///
        ///
        /// Parameter `coachingOverlayView`: The view currently active
        #[optional]
        #[unsafe(method(coachingOverlayViewDidRequestSessionReset:))]
        #[unsafe(method_family = none)]
        unsafe fn coachingOverlayViewDidRequestSessionReset(
            &self,
            coaching_overlay_view: &ARCoachingOverlayView,
        );

        #[cfg(feature = "objc2-ui-kit")]
        /// This is called when the view activate, either manually or automatically
        ///
        ///
        /// The Developer may hide their application UI in in this callback, and take other appropriate actions to allow
        /// `ARCoachingOverlayView` to take over the full screen.
        ///
        /// Parameter `coachingOverlayView`: The view that will be activated
        #[optional]
        #[unsafe(method(coachingOverlayViewWillActivate:))]
        #[unsafe(method_family = none)]
        unsafe fn coachingOverlayViewWillActivate(
            &self,
            coaching_overlay_view: &ARCoachingOverlayView,
        );

        #[cfg(feature = "objc2-ui-kit")]
        /// This is called when the view has been deactivated, either manually or automatically
        ///
        ///
        /// Parameter `coachingOverlayView`: The view that was deactivated
        #[optional]
        #[unsafe(method(coachingOverlayViewDidDeactivate:))]
        #[unsafe(method_family = none)]
        unsafe fn coachingOverlayViewDidDeactivate(
            &self,
            coaching_overlay_view: &ARCoachingOverlayView,
        );
    }
);