objc2_ui_kit/generated/
UICollisionBehavior.rs1use 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#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UICollisionBehaviorMode(pub NSUInteger);
17bitflags::bitflags! {
18 impl UICollisionBehaviorMode: NSUInteger {
19 #[doc(alias = "UICollisionBehaviorModeItems")]
20 const Items = 1<<0;
21 #[doc(alias = "UICollisionBehaviorModeBoundaries")]
22 const Boundaries = 1<<1;
23 #[doc(alias = "UICollisionBehaviorModeEverything")]
24 const Everything = NSUIntegerMax as _;
25 }
26}
27
28unsafe impl Encode for UICollisionBehaviorMode {
29 const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UICollisionBehaviorMode {
33 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_protocol!(
37 pub unsafe trait UICollisionBehaviorDelegate: NSObjectProtocol + MainThreadOnly {
39 #[cfg(all(feature = "UIDynamicBehavior", feature = "objc2-core-foundation"))]
40 #[optional]
41 #[unsafe(method(collisionBehavior:beganContactForItem:withItem:atPoint:))]
42 #[unsafe(method_family = none)]
43 unsafe fn collisionBehavior_beganContactForItem_withItem_atPoint(
44 &self,
45 behavior: &UICollisionBehavior,
46 item1: &ProtocolObject<dyn UIDynamicItem>,
47 item2: &ProtocolObject<dyn UIDynamicItem>,
48 p: CGPoint,
49 );
50
51 #[cfg(feature = "UIDynamicBehavior")]
52 #[optional]
53 #[unsafe(method(collisionBehavior:endedContactForItem:withItem:))]
54 #[unsafe(method_family = none)]
55 unsafe fn collisionBehavior_endedContactForItem_withItem(
56 &self,
57 behavior: &UICollisionBehavior,
58 item1: &ProtocolObject<dyn UIDynamicItem>,
59 item2: &ProtocolObject<dyn UIDynamicItem>,
60 );
61
62 #[cfg(all(feature = "UIDynamicBehavior", feature = "objc2-core-foundation"))]
63 #[optional]
64 #[unsafe(method(collisionBehavior:beganContactForItem:withBoundaryIdentifier:atPoint:))]
65 #[unsafe(method_family = none)]
66 unsafe fn collisionBehavior_beganContactForItem_withBoundaryIdentifier_atPoint(
67 &self,
68 behavior: &UICollisionBehavior,
69 item: &ProtocolObject<dyn UIDynamicItem>,
70 identifier: Option<&ProtocolObject<dyn NSCopying>>,
71 p: CGPoint,
72 );
73
74 #[cfg(feature = "UIDynamicBehavior")]
75 #[optional]
76 #[unsafe(method(collisionBehavior:endedContactForItem:withBoundaryIdentifier:))]
77 #[unsafe(method_family = none)]
78 unsafe fn collisionBehavior_endedContactForItem_withBoundaryIdentifier(
79 &self,
80 behavior: &UICollisionBehavior,
81 item: &ProtocolObject<dyn UIDynamicItem>,
82 identifier: Option<&ProtocolObject<dyn NSCopying>>,
83 );
84 }
85);
86
87extern_class!(
88 #[unsafe(super(UIDynamicBehavior, NSObject))]
90 #[thread_kind = MainThreadOnly]
91 #[derive(Debug, PartialEq, Eq, Hash)]
92 #[cfg(feature = "UIDynamicBehavior")]
93 pub struct UICollisionBehavior;
94);
95
96#[cfg(feature = "UIDynamicBehavior")]
97unsafe impl NSObjectProtocol for UICollisionBehavior {}
98
99#[cfg(feature = "UIDynamicBehavior")]
100impl UICollisionBehavior {
101 extern_methods!(
102 #[unsafe(method(initWithItems:))]
103 #[unsafe(method_family = init)]
104 pub unsafe fn initWithItems(
105 this: Allocated<Self>,
106 items: &NSArray<ProtocolObject<dyn UIDynamicItem>>,
107 ) -> Retained<Self>;
108
109 #[unsafe(method(addItem:))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn addItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
112
113 #[unsafe(method(removeItem:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn removeItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
116
117 #[unsafe(method(items))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
120
121 #[unsafe(method(collisionMode))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn collisionMode(&self) -> UICollisionBehaviorMode;
124
125 #[unsafe(method(setCollisionMode:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn setCollisionMode(&self, collision_mode: UICollisionBehaviorMode);
129
130 #[unsafe(method(translatesReferenceBoundsIntoBoundary))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn translatesReferenceBoundsIntoBoundary(&self) -> bool;
133
134 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundary:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn setTranslatesReferenceBoundsIntoBoundary(
138 &self,
139 translates_reference_bounds_into_boundary: bool,
140 );
141
142 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
143 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundaryWithInsets:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setTranslatesReferenceBoundsIntoBoundaryWithInsets(
146 &self,
147 insets: UIEdgeInsets,
148 );
149
150 #[cfg(feature = "UIBezierPath")]
151 #[unsafe(method(addBoundaryWithIdentifier:forPath:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn addBoundaryWithIdentifier_forPath(
154 &self,
155 identifier: &ProtocolObject<dyn NSCopying>,
156 bezier_path: &UIBezierPath,
157 );
158
159 #[cfg(feature = "objc2-core-foundation")]
160 #[unsafe(method(addBoundaryWithIdentifier:fromPoint:toPoint:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn addBoundaryWithIdentifier_fromPoint_toPoint(
163 &self,
164 identifier: &ProtocolObject<dyn NSCopying>,
165 p1: CGPoint,
166 p2: CGPoint,
167 );
168
169 #[cfg(feature = "UIBezierPath")]
170 #[unsafe(method(boundaryWithIdentifier:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn boundaryWithIdentifier(
173 &self,
174 identifier: &ProtocolObject<dyn NSCopying>,
175 ) -> Option<Retained<UIBezierPath>>;
176
177 #[unsafe(method(removeBoundaryWithIdentifier:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn removeBoundaryWithIdentifier(
180 &self,
181 identifier: &ProtocolObject<dyn NSCopying>,
182 );
183
184 #[unsafe(method(boundaryIdentifiers))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn boundaryIdentifiers(
187 &self,
188 ) -> Option<Retained<NSArray<ProtocolObject<dyn NSCopying>>>>;
189
190 #[unsafe(method(removeAllBoundaries))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn removeAllBoundaries(&self);
193
194 #[unsafe(method(collisionDelegate))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn collisionDelegate(
197 &self,
198 ) -> Option<Retained<ProtocolObject<dyn UICollisionBehaviorDelegate>>>;
199
200 #[unsafe(method(setCollisionDelegate:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn setCollisionDelegate(
205 &self,
206 collision_delegate: Option<&ProtocolObject<dyn UICollisionBehaviorDelegate>>,
207 );
208 );
209}
210
211#[cfg(feature = "UIDynamicBehavior")]
213impl UICollisionBehavior {
214 extern_methods!(
215 #[unsafe(method(init))]
216 #[unsafe(method_family = init)]
217 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
218
219 #[unsafe(method(new))]
220 #[unsafe(method_family = new)]
221 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
222 );
223}