objc2-browser-engine-kit 0.3.2

Bindings to the BrowserEngineKit 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-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use objc2_ui_kit::*;

use crate::*;

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/bedraginteractiondelegate?language=objc)
    pub unsafe trait BEDragInteractionDelegate:
        UIDragInteractionDelegate + MainThreadOnly
    {
        #[cfg(feature = "block2")]
        /// Called when the drag interaction has begun, to allow the delegate to prepare for the drag session before
        /// the system requests drag items through `-dragInteraction:itemsForBeginningSession:`.
        ///
        /// You should call the `completion` block as soon as the drag session is prepared, as to minimize the delay
        /// from the user interaction from the drag gesture. There is a system-defined timeout before the drag session is
        /// failed if the `completion` is not called in time. The `completion` block returns `YES` if the drag session did
        /// prepare successfully prepare, and `NO` otherwise, to allow clients to perform any clean-up if necessary.
        #[optional]
        #[unsafe(method(dragInteraction:prepareDragSession:completion:))]
        #[unsafe(method_family = none)]
        unsafe fn dragInteraction_prepareDragSession_completion(
            &self,
            drag_interaction: &BEDragInteraction,
            session: &ProtocolObject<dyn UIDragSession>,
            completion: &block2::DynBlock<dyn Fn() -> Bool>,
        );

        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
        /// The asynchronous counterpart to `-dragInteraction:itemsForAddingToSession:withTouchAtPoint:` to allow
        /// touches on this view to add items to an existing drag session. Please refer to the aforementioned delegate method for its full
        /// documentation.
        ///
        /// If this method is implemented, then the `UIDragInteractionDelegate` counterpart method will no longer be called.
        ///
        /// You should call the `completion` block as soon as the items are ready. There is a system-defined
        /// timeout before the system will treat the delegate call as returning an empty array. The `completion` block
        /// returns `YES` if the drag session did add items to the session successfully, and `NO` otherwise, to allow
        /// clients to perform any clean-up if necessary.
        #[optional]
        #[unsafe(method(dragInteraction:itemsForAddingToSession:forTouchAtPoint:completion:))]
        #[unsafe(method_family = none)]
        unsafe fn dragInteraction_itemsForAddingToSession_forTouchAtPoint_completion(
            &self,
            drag_interaction: &BEDragInteraction,
            session: &ProtocolObject<dyn UIDragSession>,
            point: CGPoint,
            completion: &block2::DynBlock<dyn Fn(NonNull<NSArray<UIDragItem>>) -> Bool>,
        );
    }
);

extern_class!(
    /// A `UIDragInteraction` subclass with features specific to browsers to enable asynchronous preparations and behaviours.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/browserenginekit/bedraginteraction?language=objc)
    #[unsafe(super(UIDragInteraction, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct BEDragInteraction;
);

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

extern_conformance!(
    unsafe impl UIInteraction for BEDragInteraction {}
);

impl BEDragInteraction {
    extern_methods!(
        /// The object that manages the drag interaction lifecycle.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn BEDragInteractionDelegate>>>;

        /// Creates an drag interaction with the specified delegate.
        #[unsafe(method(initWithDelegate:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate(
            this: Allocated<Self>,
            delegate: &ProtocolObject<dyn BEDragInteractionDelegate>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `UIDragInteraction`.
impl BEDragInteraction {
    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(mtm: MainThreadMarker) -> Retained<Self>;
    );
}