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