1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-core-foundation")]
6use objc2_core_foundation::*;
7use objc2_foundation::*;
8
9use crate::*;
10
11extern_class!(
12 #[unsafe(super(NSObject))]
14 #[thread_kind = MainThreadOnly]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 pub struct NSLayoutAnchor<AnchorType: ?Sized = AnyObject>;
17);
18
19unsafe impl<AnchorType: ?Sized + NSCoding> NSCoding for NSLayoutAnchor<AnchorType> {}
20
21unsafe impl<AnchorType: ?Sized> NSCopying for NSLayoutAnchor<AnchorType> {}
22
23unsafe impl<AnchorType: ?Sized + Message> CopyingHelper for NSLayoutAnchor<AnchorType> {
24 type Result = Self;
25}
26
27unsafe impl<AnchorType: ?Sized> NSObjectProtocol for NSLayoutAnchor<AnchorType> {}
28
29impl<AnchorType: Message> NSLayoutAnchor<AnchorType> {
30 extern_methods!(
31 #[cfg(feature = "NSLayoutConstraint")]
32 #[must_use]
33 #[unsafe(method(constraintEqualToAnchor:))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn constraintEqualToAnchor(
36 &self,
37 anchor: &NSLayoutAnchor<AnchorType>,
38 ) -> Retained<NSLayoutConstraint>;
39
40 #[cfg(feature = "NSLayoutConstraint")]
41 #[must_use]
42 #[unsafe(method(constraintGreaterThanOrEqualToAnchor:))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn constraintGreaterThanOrEqualToAnchor(
45 &self,
46 anchor: &NSLayoutAnchor<AnchorType>,
47 ) -> Retained<NSLayoutConstraint>;
48
49 #[cfg(feature = "NSLayoutConstraint")]
50 #[must_use]
51 #[unsafe(method(constraintLessThanOrEqualToAnchor:))]
52 #[unsafe(method_family = none)]
53 pub unsafe fn constraintLessThanOrEqualToAnchor(
54 &self,
55 anchor: &NSLayoutAnchor<AnchorType>,
56 ) -> Retained<NSLayoutConstraint>;
57
58 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
59 #[must_use]
60 #[unsafe(method(constraintEqualToAnchor:constant:))]
61 #[unsafe(method_family = none)]
62 pub unsafe fn constraintEqualToAnchor_constant(
63 &self,
64 anchor: &NSLayoutAnchor<AnchorType>,
65 c: CGFloat,
66 ) -> Retained<NSLayoutConstraint>;
67
68 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
69 #[must_use]
70 #[unsafe(method(constraintGreaterThanOrEqualToAnchor:constant:))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn constraintGreaterThanOrEqualToAnchor_constant(
73 &self,
74 anchor: &NSLayoutAnchor<AnchorType>,
75 c: CGFloat,
76 ) -> Retained<NSLayoutConstraint>;
77
78 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
79 #[must_use]
80 #[unsafe(method(constraintLessThanOrEqualToAnchor:constant:))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn constraintLessThanOrEqualToAnchor_constant(
83 &self,
84 anchor: &NSLayoutAnchor<AnchorType>,
85 c: CGFloat,
86 ) -> Retained<NSLayoutConstraint>;
87
88 #[unsafe(method(name))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn name(&self) -> Retained<NSString>;
91
92 #[unsafe(method(item))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn item(&self) -> Option<Retained<AnyObject>>;
95
96 #[unsafe(method(hasAmbiguousLayout))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn hasAmbiguousLayout(&self) -> bool;
99
100 #[cfg(feature = "NSLayoutConstraint")]
101 #[unsafe(method(constraintsAffectingLayout))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn constraintsAffectingLayout(&self) -> Retained<NSArray<NSLayoutConstraint>>;
104 );
105}
106
107impl<AnchorType: Message> NSLayoutAnchor<AnchorType> {
109 extern_methods!(
110 #[unsafe(method(init))]
111 #[unsafe(method_family = init)]
112 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
113
114 #[unsafe(method(new))]
115 #[unsafe(method_family = new)]
116 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
117 );
118}
119
120extern_class!(
121 #[unsafe(super(NSLayoutAnchor, NSObject))]
123 #[thread_kind = MainThreadOnly]
124 #[derive(Debug)]
125 pub struct NSLayoutXAxisAnchor;
126);
127
128unsafe impl NSCoding for NSLayoutXAxisAnchor {}
129
130unsafe impl NSCopying for NSLayoutXAxisAnchor {}
131
132unsafe impl CopyingHelper for NSLayoutXAxisAnchor {
133 type Result = Self;
134}
135
136unsafe impl NSObjectProtocol for NSLayoutXAxisAnchor {}
137
138impl NSLayoutXAxisAnchor {
139 extern_methods!(
140 #[unsafe(method(anchorWithOffsetToAnchor:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn anchorWithOffsetToAnchor(
143 &self,
144 other_anchor: &NSLayoutXAxisAnchor,
145 ) -> Retained<NSLayoutDimension>;
146 );
147}
148
149impl NSLayoutXAxisAnchor {
151 extern_methods!(
152 #[unsafe(method(init))]
153 #[unsafe(method_family = init)]
154 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
155
156 #[unsafe(method(new))]
157 #[unsafe(method_family = new)]
158 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
159 );
160}
161
162extern_class!(
163 #[unsafe(super(NSLayoutAnchor, NSObject))]
165 #[thread_kind = MainThreadOnly]
166 #[derive(Debug)]
167 pub struct NSLayoutYAxisAnchor;
168);
169
170unsafe impl NSCoding for NSLayoutYAxisAnchor {}
171
172unsafe impl NSCopying for NSLayoutYAxisAnchor {}
173
174unsafe impl CopyingHelper for NSLayoutYAxisAnchor {
175 type Result = Self;
176}
177
178unsafe impl NSObjectProtocol for NSLayoutYAxisAnchor {}
179
180impl NSLayoutYAxisAnchor {
181 extern_methods!(
182 #[unsafe(method(anchorWithOffsetToAnchor:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn anchorWithOffsetToAnchor(
185 &self,
186 other_anchor: &NSLayoutYAxisAnchor,
187 ) -> Retained<NSLayoutDimension>;
188 );
189}
190
191impl NSLayoutYAxisAnchor {
193 extern_methods!(
194 #[unsafe(method(init))]
195 #[unsafe(method_family = init)]
196 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
197
198 #[unsafe(method(new))]
199 #[unsafe(method_family = new)]
200 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
201 );
202}
203
204extern_class!(
205 #[unsafe(super(NSLayoutAnchor, NSObject))]
207 #[thread_kind = MainThreadOnly]
208 #[derive(Debug)]
209 pub struct NSLayoutDimension;
210);
211
212unsafe impl NSCoding for NSLayoutDimension {}
213
214unsafe impl NSCopying for NSLayoutDimension {}
215
216unsafe impl CopyingHelper for NSLayoutDimension {
217 type Result = Self;
218}
219
220unsafe impl NSObjectProtocol for NSLayoutDimension {}
221
222impl NSLayoutDimension {
223 extern_methods!(
224 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
225 #[must_use]
226 #[unsafe(method(constraintEqualToConstant:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn constraintEqualToConstant(&self, c: CGFloat) -> Retained<NSLayoutConstraint>;
229
230 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
231 #[must_use]
232 #[unsafe(method(constraintGreaterThanOrEqualToConstant:))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn constraintGreaterThanOrEqualToConstant(
235 &self,
236 c: CGFloat,
237 ) -> Retained<NSLayoutConstraint>;
238
239 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
240 #[must_use]
241 #[unsafe(method(constraintLessThanOrEqualToConstant:))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn constraintLessThanOrEqualToConstant(
244 &self,
245 c: CGFloat,
246 ) -> Retained<NSLayoutConstraint>;
247
248 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
249 #[must_use]
250 #[unsafe(method(constraintEqualToAnchor:multiplier:))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn constraintEqualToAnchor_multiplier(
253 &self,
254 anchor: &NSLayoutDimension,
255 m: CGFloat,
256 ) -> Retained<NSLayoutConstraint>;
257
258 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
259 #[must_use]
260 #[unsafe(method(constraintGreaterThanOrEqualToAnchor:multiplier:))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn constraintGreaterThanOrEqualToAnchor_multiplier(
263 &self,
264 anchor: &NSLayoutDimension,
265 m: CGFloat,
266 ) -> Retained<NSLayoutConstraint>;
267
268 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
269 #[must_use]
270 #[unsafe(method(constraintLessThanOrEqualToAnchor:multiplier:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn constraintLessThanOrEqualToAnchor_multiplier(
273 &self,
274 anchor: &NSLayoutDimension,
275 m: CGFloat,
276 ) -> Retained<NSLayoutConstraint>;
277
278 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
279 #[must_use]
280 #[unsafe(method(constraintEqualToAnchor:multiplier:constant:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn constraintEqualToAnchor_multiplier_constant(
283 &self,
284 anchor: &NSLayoutDimension,
285 m: CGFloat,
286 c: CGFloat,
287 ) -> Retained<NSLayoutConstraint>;
288
289 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
290 #[must_use]
291 #[unsafe(method(constraintGreaterThanOrEqualToAnchor:multiplier:constant:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn constraintGreaterThanOrEqualToAnchor_multiplier_constant(
294 &self,
295 anchor: &NSLayoutDimension,
296 m: CGFloat,
297 c: CGFloat,
298 ) -> Retained<NSLayoutConstraint>;
299
300 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
301 #[must_use]
302 #[unsafe(method(constraintLessThanOrEqualToAnchor:multiplier:constant:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn constraintLessThanOrEqualToAnchor_multiplier_constant(
305 &self,
306 anchor: &NSLayoutDimension,
307 m: CGFloat,
308 c: CGFloat,
309 ) -> Retained<NSLayoutConstraint>;
310 );
311}
312
313impl NSLayoutDimension {
315 extern_methods!(
316 #[unsafe(method(init))]
317 #[unsafe(method_family = init)]
318 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
319
320 #[unsafe(method(new))]
321 #[unsafe(method_family = new)]
322 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
323 );
324}
325
326impl NSLayoutXAxisAnchor {
328 extern_methods!(
329 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
330 #[must_use]
331 #[unsafe(method(constraintEqualToSystemSpacingAfterAnchor:multiplier:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn constraintEqualToSystemSpacingAfterAnchor_multiplier(
334 &self,
335 anchor: &NSLayoutXAxisAnchor,
336 multiplier: CGFloat,
337 ) -> Retained<NSLayoutConstraint>;
338
339 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
340 #[must_use]
341 #[unsafe(method(constraintGreaterThanOrEqualToSystemSpacingAfterAnchor:multiplier:))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn constraintGreaterThanOrEqualToSystemSpacingAfterAnchor_multiplier(
344 &self,
345 anchor: &NSLayoutXAxisAnchor,
346 multiplier: CGFloat,
347 ) -> Retained<NSLayoutConstraint>;
348
349 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
350 #[must_use]
351 #[unsafe(method(constraintLessThanOrEqualToSystemSpacingAfterAnchor:multiplier:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn constraintLessThanOrEqualToSystemSpacingAfterAnchor_multiplier(
354 &self,
355 anchor: &NSLayoutXAxisAnchor,
356 multiplier: CGFloat,
357 ) -> Retained<NSLayoutConstraint>;
358 );
359}
360
361impl NSLayoutYAxisAnchor {
363 extern_methods!(
364 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
365 #[must_use]
366 #[unsafe(method(constraintEqualToSystemSpacingBelowAnchor:multiplier:))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn constraintEqualToSystemSpacingBelowAnchor_multiplier(
369 &self,
370 anchor: &NSLayoutYAxisAnchor,
371 multiplier: CGFloat,
372 ) -> Retained<NSLayoutConstraint>;
373
374 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
375 #[must_use]
376 #[unsafe(method(constraintGreaterThanOrEqualToSystemSpacingBelowAnchor:multiplier:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn constraintGreaterThanOrEqualToSystemSpacingBelowAnchor_multiplier(
379 &self,
380 anchor: &NSLayoutYAxisAnchor,
381 multiplier: CGFloat,
382 ) -> Retained<NSLayoutConstraint>;
383
384 #[cfg(all(feature = "NSLayoutConstraint", feature = "objc2-core-foundation"))]
385 #[must_use]
386 #[unsafe(method(constraintLessThanOrEqualToSystemSpacingBelowAnchor:multiplier:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn constraintLessThanOrEqualToSystemSpacingBelowAnchor_multiplier(
389 &self,
390 anchor: &NSLayoutYAxisAnchor,
391 multiplier: CGFloat,
392 ) -> Retained<NSLayoutConstraint>;
393 );
394}