//! 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/uidynamicitemcollisionboundstype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIDynamicItemCollisionBoundsType(pub NSUInteger);
impl UIDynamicItemCollisionBoundsType {
    #[doc(alias = "UIDynamicItemCollisionBoundsTypeRectangle")]
    pub const Rectangle: Self = Self(0);
    #[doc(alias = "UIDynamicItemCollisionBoundsTypeEllipse")]
    pub const Ellipse: Self = Self(1);
    #[doc(alias = "UIDynamicItemCollisionBoundsTypePath")]
    pub const Path: Self = Self(2);
}

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicitem?language=objc)
    pub unsafe trait UIDynamicItem: NSObjectProtocol + MainThreadOnly {
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(center))]
        #[unsafe(method_family = none)]
        fn center(&self) -> CGPoint;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`center`][Self::center].
        #[unsafe(method(setCenter:))]
        #[unsafe(method_family = none)]
        fn setCenter(&self, center: CGPoint);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(bounds))]
        #[unsafe(method_family = none)]
        fn bounds(&self) -> CGRect;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(transform))]
        #[unsafe(method_family = none)]
        fn transform(&self) -> CGAffineTransform;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`transform`][Self::transform].
        #[unsafe(method(setTransform:))]
        #[unsafe(method_family = none)]
        fn setTransform(&self, transform: CGAffineTransform);

        /// The collision type represents how the dynamics system will evaluate collisions with
        /// respect to the dynamic item. defaults to UIDynamicItemCollisionBoundsTypeRectangle
        #[optional]
        #[unsafe(method(collisionBoundsType))]
        #[unsafe(method_family = none)]
        fn collisionBoundsType(&self) -> UIDynamicItemCollisionBoundsType;

        #[cfg(feature = "UIBezierPath")]
        /// The path must represent a convex polygon with counter clockwise winding and no self intersection.
        /// The point (0,0) in the path corresponds to the dynamic item's center.
        #[optional]
        #[unsafe(method(collisionBoundingPath))]
        #[unsafe(method_family = none)]
        fn collisionBoundingPath(&self) -> Retained<UIBezierPath>;
    }
);

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

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

extern_conformance!(
    unsafe impl UIDynamicItem for UIDynamicItemGroup {}
);

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

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

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

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

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

impl UIDynamicBehavior {
    extern_methods!(
        #[unsafe(method(addChildBehavior:))]
        #[unsafe(method_family = none)]
        pub fn addChildBehavior(&self, behavior: &UIDynamicBehavior);

        #[unsafe(method(removeChildBehavior:))]
        #[unsafe(method_family = none)]
        pub fn removeChildBehavior(&self, behavior: &UIDynamicBehavior);

        #[unsafe(method(childBehaviors))]
        #[unsafe(method_family = none)]
        pub fn childBehaviors(&self) -> Retained<NSArray<UIDynamicBehavior>>;

        #[cfg(feature = "block2")]
        #[unsafe(method(action))]
        #[unsafe(method_family = none)]
        pub fn action(&self) -> *mut block2::DynBlock<dyn Fn()>;

        #[cfg(feature = "block2")]
        /// Setter for [`action`][Self::action].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAction:))]
        #[unsafe(method_family = none)]
        pub fn setAction(&self, action: Option<&block2::DynBlock<dyn Fn()>>);

        #[cfg(feature = "UIDynamicAnimator")]
        #[unsafe(method(willMoveToAnimator:))]
        #[unsafe(method_family = none)]
        pub fn willMoveToAnimator(&self, dynamic_animator: Option<&UIDynamicAnimator>);

        #[cfg(feature = "UIDynamicAnimator")]
        #[unsafe(method(dynamicAnimator))]
        #[unsafe(method_family = none)]
        pub fn dynamicAnimator(&self) -> Option<Retained<UIDynamicAnimator>>;
    );
}

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