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