//! 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 crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollisionbehaviormode?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UICollisionBehaviorMode(pub NSUInteger);
bitflags::bitflags! {
    impl UICollisionBehaviorMode: NSUInteger {
        #[doc(alias = "UICollisionBehaviorModeItems")]
        const Items = 1<<0;
        #[doc(alias = "UICollisionBehaviorModeBoundaries")]
        const Boundaries = 1<<1;
        #[doc(alias = "UICollisionBehaviorModeEverything")]
        const Everything = NSUIntegerMax as _;
    }
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollisionbehaviordelegate?language=objc)
    pub unsafe trait UICollisionBehaviorDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIDynamicBehavior", feature = "objc2-core-foundation"))]
        #[optional]
        #[unsafe(method(collisionBehavior:beganContactForItem:withItem:atPoint:))]
        #[unsafe(method_family = none)]
        fn collisionBehavior_beganContactForItem_withItem_atPoint(
            &self,
            behavior: &UICollisionBehavior,
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            p: CGPoint,
        );

        #[cfg(feature = "UIDynamicBehavior")]
        #[optional]
        #[unsafe(method(collisionBehavior:endedContactForItem:withItem:))]
        #[unsafe(method_family = none)]
        fn collisionBehavior_endedContactForItem_withItem(
            &self,
            behavior: &UICollisionBehavior,
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
        );

        #[cfg(all(feature = "UIDynamicBehavior", feature = "objc2-core-foundation"))]
        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[optional]
        #[unsafe(method(collisionBehavior:beganContactForItem:withBoundaryIdentifier:atPoint:))]
        #[unsafe(method_family = none)]
        unsafe fn collisionBehavior_beganContactForItem_withBoundaryIdentifier_atPoint(
            &self,
            behavior: &UICollisionBehavior,
            item: &ProtocolObject<dyn UIDynamicItem>,
            identifier: Option<&ProtocolObject<dyn NSCopying>>,
            p: CGPoint,
        );

        #[cfg(feature = "UIDynamicBehavior")]
        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[optional]
        #[unsafe(method(collisionBehavior:endedContactForItem:withBoundaryIdentifier:))]
        #[unsafe(method_family = none)]
        unsafe fn collisionBehavior_endedContactForItem_withBoundaryIdentifier(
            &self,
            behavior: &UICollisionBehavior,
            item: &ProtocolObject<dyn UIDynamicItem>,
            identifier: Option<&ProtocolObject<dyn NSCopying>>,
        );
    }
);

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

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

#[cfg(feature = "UIDynamicBehavior")]
impl UICollisionBehavior {
    extern_methods!(
        #[unsafe(method(initWithItems:))]
        #[unsafe(method_family = init)]
        pub fn initWithItems(
            this: Allocated<Self>,
            items: &NSArray<ProtocolObject<dyn UIDynamicItem>>,
        ) -> Retained<Self>;

        #[unsafe(method(addItem:))]
        #[unsafe(method_family = none)]
        pub fn addItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);

        #[unsafe(method(removeItem:))]
        #[unsafe(method_family = none)]
        pub fn removeItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);

        #[unsafe(method(items))]
        #[unsafe(method_family = none)]
        pub fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;

        #[unsafe(method(collisionMode))]
        #[unsafe(method_family = none)]
        pub fn collisionMode(&self) -> UICollisionBehaviorMode;

        /// Setter for [`collisionMode`][Self::collisionMode].
        #[unsafe(method(setCollisionMode:))]
        #[unsafe(method_family = none)]
        pub fn setCollisionMode(&self, collision_mode: UICollisionBehaviorMode);

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

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

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        #[unsafe(method(setTranslatesReferenceBoundsIntoBoundaryWithInsets:))]
        #[unsafe(method_family = none)]
        pub fn setTranslatesReferenceBoundsIntoBoundaryWithInsets(&self, insets: UIEdgeInsets);

        #[cfg(feature = "UIBezierPath")]
        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[unsafe(method(addBoundaryWithIdentifier:forPath:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addBoundaryWithIdentifier_forPath(
            &self,
            identifier: &ProtocolObject<dyn NSCopying>,
            bezier_path: &UIBezierPath,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[unsafe(method(addBoundaryWithIdentifier:fromPoint:toPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addBoundaryWithIdentifier_fromPoint_toPoint(
            &self,
            identifier: &ProtocolObject<dyn NSCopying>,
            p1: CGPoint,
            p2: CGPoint,
        );

        #[cfg(feature = "UIBezierPath")]
        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[unsafe(method(boundaryWithIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn boundaryWithIdentifier(
            &self,
            identifier: &ProtocolObject<dyn NSCopying>,
        ) -> Option<Retained<UIBezierPath>>;

        /// # Safety
        ///
        /// `identifier` should be of the correct type.
        #[unsafe(method(removeBoundaryWithIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeBoundaryWithIdentifier(
            &self,
            identifier: &ProtocolObject<dyn NSCopying>,
        );

        #[unsafe(method(boundaryIdentifiers))]
        #[unsafe(method_family = none)]
        pub fn boundaryIdentifiers(
            &self,
        ) -> Option<Retained<NSArray<ProtocolObject<dyn NSCopying>>>>;

        #[unsafe(method(removeAllBoundaries))]
        #[unsafe(method_family = none)]
        pub fn removeAllBoundaries(&self);

        #[unsafe(method(collisionDelegate))]
        #[unsafe(method_family = none)]
        pub fn collisionDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UICollisionBehaviorDelegate>>>;

        /// Setter for [`collisionDelegate`][Self::collisionDelegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setCollisionDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setCollisionDelegate(
            &self,
            collision_delegate: Option<&ProtocolObject<dyn UICollisionBehaviorDelegate>>,
        );
    );
}

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