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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicanimatordelegate?language=objc)
    pub unsafe trait UIDynamicAnimatorDelegate: NSObjectProtocol + MainThreadOnly {
        #[optional]
        #[unsafe(method(dynamicAnimatorWillResume:))]
        #[unsafe(method_family = none)]
        fn dynamicAnimatorWillResume(&self, animator: &UIDynamicAnimator);

        #[optional]
        #[unsafe(method(dynamicAnimatorDidPause:))]
        #[unsafe(method_family = none)]
        fn dynamicAnimatorDidPause(&self, animator: &UIDynamicAnimator);
    }
);

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

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

impl UIDynamicAnimator {
    extern_methods!(
        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(initWithReferenceView:))]
        #[unsafe(method_family = init)]
        pub fn initWithReferenceView(this: Allocated<Self>, view: &UIView) -> Retained<Self>;

        #[cfg(feature = "UIDynamicBehavior")]
        #[unsafe(method(addBehavior:))]
        #[unsafe(method_family = none)]
        pub fn addBehavior(&self, behavior: &UIDynamicBehavior);

        #[cfg(feature = "UIDynamicBehavior")]
        #[unsafe(method(removeBehavior:))]
        #[unsafe(method_family = none)]
        pub fn removeBehavior(&self, behavior: &UIDynamicBehavior);

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

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[unsafe(method(referenceView))]
        #[unsafe(method_family = none)]
        pub fn referenceView(&self, mtm: MainThreadMarker) -> Option<Retained<UIView>>;

        #[cfg(feature = "UIDynamicBehavior")]
        #[unsafe(method(behaviors))]
        #[unsafe(method_family = none)]
        pub fn behaviors(&self, mtm: MainThreadMarker) -> Retained<NSArray<UIDynamicBehavior>>;

        #[cfg(all(feature = "UIDynamicBehavior", feature = "objc2-core-foundation"))]
        #[unsafe(method(itemsInRect:))]
        #[unsafe(method_family = none)]
        pub fn itemsInRect(
            &self,
            rect: CGRect,
            mtm: MainThreadMarker,
        ) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;

        #[cfg(feature = "UIDynamicBehavior")]
        #[unsafe(method(updateItemUsingCurrentState:))]
        #[unsafe(method_family = none)]
        pub fn updateItemUsingCurrentState(&self, item: &ProtocolObject<dyn UIDynamicItem>);

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

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

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
            mtm: MainThreadMarker,
        ) -> Option<Retained<ProtocolObject<dyn UIDynamicAnimatorDelegate>>>;

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

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

impl DefaultRetained for UIDynamicAnimator {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// UICollectionViewAdditions.
impl UIDynamicAnimator {
    extern_methods!(
        #[cfg(feature = "UICollectionViewLayout")]
        #[unsafe(method(initWithCollectionViewLayout:))]
        #[unsafe(method_family = init)]
        pub fn initWithCollectionViewLayout(
            this: Allocated<Self>,
            layout: &UICollectionViewLayout,
        ) -> Retained<Self>;

        #[cfg(feature = "UICollectionViewLayout")]
        #[unsafe(method(layoutAttributesForCellAtIndexPath:))]
        #[unsafe(method_family = none)]
        pub fn layoutAttributesForCellAtIndexPath(
            &self,
            index_path: &NSIndexPath,
            mtm: MainThreadMarker,
        ) -> Option<Retained<UICollectionViewLayoutAttributes>>;

        #[cfg(feature = "UICollectionViewLayout")]
        #[unsafe(method(layoutAttributesForSupplementaryViewOfKind:atIndexPath:))]
        #[unsafe(method_family = none)]
        pub fn layoutAttributesForSupplementaryViewOfKind_atIndexPath(
            &self,
            kind: &NSString,
            index_path: &NSIndexPath,
            mtm: MainThreadMarker,
        ) -> Option<Retained<UICollectionViewLayoutAttributes>>;

        #[cfg(feature = "UICollectionViewLayout")]
        #[unsafe(method(layoutAttributesForDecorationViewOfKind:atIndexPath:))]
        #[unsafe(method_family = none)]
        pub fn layoutAttributesForDecorationViewOfKind_atIndexPath(
            &self,
            decoration_view_kind: &NSString,
            index_path: &NSIndexPath,
            mtm: MainThreadMarker,
        ) -> Option<Retained<UICollectionViewLayoutAttributes>>;
    );
}
