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")]
97extern_conformance!(
98 unsafe impl NSObjectProtocol for UICollisionBehavior {}
99);
100
101#[cfg(feature = "UIDynamicBehavior")]
102impl UICollisionBehavior {
103 extern_methods!(
104 #[unsafe(method(initWithItems:))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn initWithItems(
107 this: Allocated<Self>,
108 items: &NSArray<ProtocolObject<dyn UIDynamicItem>>,
109 ) -> Retained<Self>;
110
111 #[unsafe(method(addItem:))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn addItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
114
115 #[unsafe(method(removeItem:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn removeItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
118
119 #[unsafe(method(items))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
122
123 #[unsafe(method(collisionMode))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn collisionMode(&self) -> UICollisionBehaviorMode;
126
127 #[unsafe(method(setCollisionMode:))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn setCollisionMode(&self, collision_mode: UICollisionBehaviorMode);
131
132 #[unsafe(method(translatesReferenceBoundsIntoBoundary))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn translatesReferenceBoundsIntoBoundary(&self) -> bool;
135
136 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundary:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn setTranslatesReferenceBoundsIntoBoundary(
140 &self,
141 translates_reference_bounds_into_boundary: bool,
142 );
143
144 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
145 #[unsafe(method(setTranslatesReferenceBoundsIntoBoundaryWithInsets:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setTranslatesReferenceBoundsIntoBoundaryWithInsets(
148 &self,
149 insets: UIEdgeInsets,
150 );
151
152 #[cfg(feature = "UIBezierPath")]
153 #[unsafe(method(addBoundaryWithIdentifier:forPath:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn addBoundaryWithIdentifier_forPath(
156 &self,
157 identifier: &ProtocolObject<dyn NSCopying>,
158 bezier_path: &UIBezierPath,
159 );
160
161 #[cfg(feature = "objc2-core-foundation")]
162 #[unsafe(method(addBoundaryWithIdentifier:fromPoint:toPoint:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn addBoundaryWithIdentifier_fromPoint_toPoint(
165 &self,
166 identifier: &ProtocolObject<dyn NSCopying>,
167 p1: CGPoint,
168 p2: CGPoint,
169 );
170
171 #[cfg(feature = "UIBezierPath")]
172 #[unsafe(method(boundaryWithIdentifier:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn boundaryWithIdentifier(
175 &self,
176 identifier: &ProtocolObject<dyn NSCopying>,
177 ) -> Option<Retained<UIBezierPath>>;
178
179 #[unsafe(method(removeBoundaryWithIdentifier:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn removeBoundaryWithIdentifier(
182 &self,
183 identifier: &ProtocolObject<dyn NSCopying>,
184 );
185
186 #[unsafe(method(boundaryIdentifiers))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn boundaryIdentifiers(
189 &self,
190 ) -> Option<Retained<NSArray<ProtocolObject<dyn NSCopying>>>>;
191
192 #[unsafe(method(removeAllBoundaries))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn removeAllBoundaries(&self);
195
196 #[unsafe(method(collisionDelegate))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn collisionDelegate(
199 &self,
200 ) -> Option<Retained<ProtocolObject<dyn UICollisionBehaviorDelegate>>>;
201
202 #[unsafe(method(setCollisionDelegate:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn setCollisionDelegate(
207 &self,
208 collision_delegate: Option<&ProtocolObject<dyn UICollisionBehaviorDelegate>>,
209 );
210 );
211}
212
213#[cfg(feature = "UIDynamicBehavior")]
215impl UICollisionBehavior {
216 extern_methods!(
217 #[unsafe(method(init))]
218 #[unsafe(method_family = init)]
219 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
220
221 #[unsafe(method(new))]
222 #[unsafe(method_family = new)]
223 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
224 );
225}