objc2_ui_kit/generated/
UIDynamicBehavior.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicitemcollisionboundstype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIDynamicItemCollisionBoundsType(pub NSUInteger);
17impl UIDynamicItemCollisionBoundsType {
18    #[doc(alias = "UIDynamicItemCollisionBoundsTypeRectangle")]
19    pub const Rectangle: Self = Self(0);
20    #[doc(alias = "UIDynamicItemCollisionBoundsTypeEllipse")]
21    pub const Ellipse: Self = Self(1);
22    #[doc(alias = "UIDynamicItemCollisionBoundsTypePath")]
23    pub const Path: Self = Self(2);
24}
25
26unsafe impl Encode for UIDynamicItemCollisionBoundsType {
27    const ENCODING: Encoding = NSUInteger::ENCODING;
28}
29
30unsafe impl RefEncode for UIDynamicItemCollisionBoundsType {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34extern_protocol!(
35    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicitem?language=objc)
36    pub unsafe trait UIDynamicItem: NSObjectProtocol + MainThreadOnly {
37        #[cfg(feature = "objc2-core-foundation")]
38        #[unsafe(method(center))]
39        #[unsafe(method_family = none)]
40        unsafe fn center(&self) -> CGPoint;
41
42        #[cfg(feature = "objc2-core-foundation")]
43        /// Setter for [`center`][Self::center].
44        #[unsafe(method(setCenter:))]
45        #[unsafe(method_family = none)]
46        unsafe fn setCenter(&self, center: CGPoint);
47
48        #[cfg(feature = "objc2-core-foundation")]
49        #[unsafe(method(bounds))]
50        #[unsafe(method_family = none)]
51        unsafe fn bounds(&self) -> CGRect;
52
53        #[cfg(feature = "objc2-core-foundation")]
54        #[unsafe(method(transform))]
55        #[unsafe(method_family = none)]
56        unsafe fn transform(&self) -> CGAffineTransform;
57
58        #[cfg(feature = "objc2-core-foundation")]
59        /// Setter for [`transform`][Self::transform].
60        #[unsafe(method(setTransform:))]
61        #[unsafe(method_family = none)]
62        unsafe fn setTransform(&self, transform: CGAffineTransform);
63
64        /// The collision type represents how the dynamics system will evaluate collisions with
65        /// respect to the dynamic item. defaults to UIDynamicItemCollisionBoundsTypeRectangle
66        #[optional]
67        #[unsafe(method(collisionBoundsType))]
68        #[unsafe(method_family = none)]
69        unsafe fn collisionBoundsType(&self) -> UIDynamicItemCollisionBoundsType;
70
71        #[cfg(feature = "UIBezierPath")]
72        /// The path must represent a convex polygon with counter clockwise winding and no self intersection.
73        /// The point (0,0) in the path corresponds to the dynamic item's center.
74        #[optional]
75        #[unsafe(method(collisionBoundingPath))]
76        #[unsafe(method_family = none)]
77        unsafe fn collisionBoundingPath(&self) -> Retained<UIBezierPath>;
78    }
79);
80
81extern_class!(
82    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicitemgroup?language=objc)
83    #[unsafe(super(NSObject))]
84    #[thread_kind = MainThreadOnly]
85    #[derive(Debug, PartialEq, Eq, Hash)]
86    pub struct UIDynamicItemGroup;
87);
88
89unsafe impl NSObjectProtocol for UIDynamicItemGroup {}
90
91unsafe impl UIDynamicItem for UIDynamicItemGroup {}
92
93impl UIDynamicItemGroup {
94    extern_methods!(
95        #[unsafe(method(initWithItems:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithItems(
98            this: Allocated<Self>,
99            items: &NSArray<ProtocolObject<dyn UIDynamicItem>>,
100        ) -> Retained<Self>;
101
102        #[unsafe(method(items))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
105    );
106}
107
108/// Methods declared on superclass `NSObject`.
109impl UIDynamicItemGroup {
110    extern_methods!(
111        #[unsafe(method(init))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
114
115        #[unsafe(method(new))]
116        #[unsafe(method_family = new)]
117        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
118    );
119}
120
121extern_class!(
122    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidynamicbehavior?language=objc)
123    #[unsafe(super(NSObject))]
124    #[thread_kind = MainThreadOnly]
125    #[derive(Debug, PartialEq, Eq, Hash)]
126    pub struct UIDynamicBehavior;
127);
128
129unsafe impl NSObjectProtocol for UIDynamicBehavior {}
130
131impl UIDynamicBehavior {
132    extern_methods!(
133        #[unsafe(method(addChildBehavior:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn addChildBehavior(&self, behavior: &UIDynamicBehavior);
136
137        #[unsafe(method(removeChildBehavior:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn removeChildBehavior(&self, behavior: &UIDynamicBehavior);
140
141        #[unsafe(method(childBehaviors))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn childBehaviors(&self) -> Retained<NSArray<UIDynamicBehavior>>;
144
145        #[cfg(feature = "block2")]
146        #[unsafe(method(action))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn action(&self) -> *mut block2::Block<dyn Fn()>;
149
150        #[cfg(feature = "block2")]
151        /// Setter for [`action`][Self::action].
152        #[unsafe(method(setAction:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn setAction(&self, action: Option<&block2::Block<dyn Fn()>>);
155
156        #[cfg(feature = "UIDynamicAnimator")]
157        #[unsafe(method(willMoveToAnimator:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn willMoveToAnimator(&self, dynamic_animator: Option<&UIDynamicAnimator>);
160
161        #[cfg(feature = "UIDynamicAnimator")]
162        #[unsafe(method(dynamicAnimator))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn dynamicAnimator(&self) -> Option<Retained<UIDynamicAnimator>>;
165    );
166}
167
168/// Methods declared on superclass `NSObject`.
169impl UIDynamicBehavior {
170    extern_methods!(
171        #[unsafe(method(init))]
172        #[unsafe(method_family = init)]
173        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
174
175        #[unsafe(method(new))]
176        #[unsafe(method_family = new)]
177        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
178    );
179}