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 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 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]
67 #[unsafe(method(collisionBehavior:beganContactForItem:withBoundaryIdentifier:atPoint:))]
68 #[unsafe(method_family = none)]
69 unsafe fn collisionBehavior_beganContactForItem_withBoundaryIdentifier_atPoint(
70 &self,
71 behavior: &UICollisionBehavior,
72 item: &ProtocolObject<dyn UIDynamicItem>,
73 identifier: Option<&ProtocolObject<dyn NSCopying>>,
74 p: CGPoint,
75 );
76
77 #[cfg(feature = "UIDynamicBehavior")]
78 #[optional]
82 #[unsafe(method(collisionBehavior:endedContactForItem:withBoundaryIdentifier:))]
83 #[unsafe(method_family = none)]
84 unsafe fn collisionBehavior_endedContactForItem_withBoundaryIdentifier(
85 &self,
86 behavior: &UICollisionBehavior,
87 item: &ProtocolObject<dyn UIDynamicItem>,
88 identifier: Option<&ProtocolObject<dyn NSCopying>>,
89 );
90 }
91);
92
93extern_class!(
94 #[unsafe(super(UIDynamicBehavior, NSObject))]
96 #[thread_kind = MainThreadOnly]
97 #[derive(Debug, PartialEq, Eq, Hash)]
98 #[cfg(feature = "UIDynamicBehavior")]
99 pub struct UICollisionBehavior;
100);
101
102#[cfg(feature = "UIDynamicBehavior")]
103extern_conformance!(
104 unsafe impl NSObjectProtocol for UICollisionBehavior {}
105);
106
107#[cfg(feature = "UIDynamicBehavior")]
108impl UICollisionBehavior {
109 extern_methods!(
110 #[unsafe(method(initWithItems:))]
111 #[unsafe(method_family = init)]
112 pub fn initWithItems(
113 this: Allocated<Self>,
114 items: &NSArray<ProtocolObject<dyn UIDynamicItem>>,
115 ) -> Retained<Self>;
116
117 #[unsafe(method(addItem:))]
118 #[unsafe(method_family = none)]
119 pub fn addItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
120
121 #[unsafe(method(removeItem:))]
122 #[unsafe(method_family = none)]
123 pub fn removeItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
124
125 #[unsafe(method(items))]
126 #[unsafe(method_family = none)]
127 pub fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
128
129 #[unsafe(method(collisionMode))]
130 #[unsafe(method_family = none)]
131 pub fn collisionMode(&self) -> UICollisionBehaviorMode;
132
133 #[unsafe(method(setCollisionMode:))]
135 #[unsafe(method_family = none)]
136 pub fn setCollisionMode(&self, collision_mode: UICollisionBehaviorMode);
137
138 #[unsafe(method(translatesReferenceBoundsIntoBoundary))]
139 #[unsafe(method_family = none)]
140 pub fn translatesReferenceBoundsIntoBoundary(&self) -> bool;
141
142 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundary:))]
144 #[unsafe(method_family = none)]
145 pub fn setTranslatesReferenceBoundsIntoBoundary(
146 &self,
147 translates_reference_bounds_into_boundary: bool,
148 );
149
150 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
151 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundaryWithInsets:))]
152 #[unsafe(method_family = none)]
153 pub fn setTranslatesReferenceBoundsIntoBoundaryWithInsets(&self, insets: UIEdgeInsets);
154
155 #[cfg(feature = "UIBezierPath")]
156 #[unsafe(method(addBoundaryWithIdentifier:forPath:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn addBoundaryWithIdentifier_forPath(
162 &self,
163 identifier: &ProtocolObject<dyn NSCopying>,
164 bezier_path: &UIBezierPath,
165 );
166
167 #[cfg(feature = "objc2-core-foundation")]
168 #[unsafe(method(addBoundaryWithIdentifier:fromPoint:toPoint:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn addBoundaryWithIdentifier_fromPoint_toPoint(
174 &self,
175 identifier: &ProtocolObject<dyn NSCopying>,
176 p1: CGPoint,
177 p2: CGPoint,
178 );
179
180 #[cfg(feature = "UIBezierPath")]
181 #[unsafe(method(boundaryWithIdentifier:))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn boundaryWithIdentifier(
187 &self,
188 identifier: &ProtocolObject<dyn NSCopying>,
189 ) -> Option<Retained<UIBezierPath>>;
190
191 #[unsafe(method(removeBoundaryWithIdentifier:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn removeBoundaryWithIdentifier(
197 &self,
198 identifier: &ProtocolObject<dyn NSCopying>,
199 );
200
201 #[unsafe(method(boundaryIdentifiers))]
202 #[unsafe(method_family = none)]
203 pub fn boundaryIdentifiers(
204 &self,
205 ) -> Option<Retained<NSArray<ProtocolObject<dyn NSCopying>>>>;
206
207 #[unsafe(method(removeAllBoundaries))]
208 #[unsafe(method_family = none)]
209 pub fn removeAllBoundaries(&self);
210
211 #[unsafe(method(collisionDelegate))]
212 #[unsafe(method_family = none)]
213 pub fn collisionDelegate(
214 &self,
215 ) -> Option<Retained<ProtocolObject<dyn UICollisionBehaviorDelegate>>>;
216
217 #[unsafe(method(setCollisionDelegate:))]
221 #[unsafe(method_family = none)]
222 pub fn setCollisionDelegate(
223 &self,
224 collision_delegate: Option<&ProtocolObject<dyn UICollisionBehaviorDelegate>>,
225 );
226 );
227}
228
229#[cfg(feature = "UIDynamicBehavior")]
231impl UICollisionBehavior {
232 extern_methods!(
233 #[unsafe(method(init))]
234 #[unsafe(method_family = init)]
235 pub fn init(this: Allocated<Self>) -> Retained<Self>;
236
237 #[unsafe(method(new))]
238 #[unsafe(method_family = new)]
239 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
240 );
241}