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