objc2_ui_kit/generated/
NSLayoutConstraint.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
12pub type UILayoutPriority = c_float;
15
16pub static UILayoutPriorityRequired: UILayoutPriority = 1000 as _;
18
19pub static UILayoutPriorityDefaultHigh: UILayoutPriority = 750 as _;
21
22pub static UILayoutPriorityDragThatCanResizeScene: UILayoutPriority = 510 as _;
24
25pub static UILayoutPrioritySceneSizeStayPut: UILayoutPriority = 500 as _;
27
28pub static UILayoutPriorityDragThatCannotResizeScene: UILayoutPriority = 490 as _;
30
31pub static UILayoutPriorityDefaultLow: UILayoutPriority = 250 as _;
33
34pub static UILayoutPriorityFittingSizeLevel: UILayoutPriority = 50 as _;
36
37#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct NSLayoutRelation(pub NSInteger);
42impl NSLayoutRelation {
43 #[doc(alias = "NSLayoutRelationLessThanOrEqual")]
44 pub const LessThanOrEqual: Self = Self(-1);
45 #[doc(alias = "NSLayoutRelationEqual")]
46 pub const Equal: Self = Self(0);
47 #[doc(alias = "NSLayoutRelationGreaterThanOrEqual")]
48 pub const GreaterThanOrEqual: Self = Self(1);
49}
50
51unsafe impl Encode for NSLayoutRelation {
52 const ENCODING: Encoding = NSInteger::ENCODING;
53}
54
55unsafe impl RefEncode for NSLayoutRelation {
56 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59#[repr(transparent)]
62#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
63pub struct NSLayoutAttribute(pub NSInteger);
64impl NSLayoutAttribute {
65 #[doc(alias = "NSLayoutAttributeLeft")]
66 pub const Left: Self = Self(1);
67 #[doc(alias = "NSLayoutAttributeRight")]
68 pub const Right: Self = Self(2);
69 #[doc(alias = "NSLayoutAttributeTop")]
70 pub const Top: Self = Self(3);
71 #[doc(alias = "NSLayoutAttributeBottom")]
72 pub const Bottom: Self = Self(4);
73 #[doc(alias = "NSLayoutAttributeLeading")]
74 pub const Leading: Self = Self(5);
75 #[doc(alias = "NSLayoutAttributeTrailing")]
76 pub const Trailing: Self = Self(6);
77 #[doc(alias = "NSLayoutAttributeWidth")]
78 pub const Width: Self = Self(7);
79 #[doc(alias = "NSLayoutAttributeHeight")]
80 pub const Height: Self = Self(8);
81 #[doc(alias = "NSLayoutAttributeCenterX")]
82 pub const CenterX: Self = Self(9);
83 #[doc(alias = "NSLayoutAttributeCenterY")]
84 pub const CenterY: Self = Self(10);
85 #[doc(alias = "NSLayoutAttributeLastBaseline")]
86 pub const LastBaseline: Self = Self(11);
87 #[doc(alias = "NSLayoutAttributeBaseline")]
88 pub const Baseline: Self = Self(NSLayoutAttribute::LastBaseline.0);
89 #[doc(alias = "NSLayoutAttributeFirstBaseline")]
90 pub const FirstBaseline: Self = Self(12);
91 #[doc(alias = "NSLayoutAttributeLeftMargin")]
92 pub const LeftMargin: Self = Self(13);
93 #[doc(alias = "NSLayoutAttributeRightMargin")]
94 pub const RightMargin: Self = Self(14);
95 #[doc(alias = "NSLayoutAttributeTopMargin")]
96 pub const TopMargin: Self = Self(15);
97 #[doc(alias = "NSLayoutAttributeBottomMargin")]
98 pub const BottomMargin: Self = Self(16);
99 #[doc(alias = "NSLayoutAttributeLeadingMargin")]
100 pub const LeadingMargin: Self = Self(17);
101 #[doc(alias = "NSLayoutAttributeTrailingMargin")]
102 pub const TrailingMargin: Self = Self(18);
103 #[doc(alias = "NSLayoutAttributeCenterXWithinMargins")]
104 pub const CenterXWithinMargins: Self = Self(19);
105 #[doc(alias = "NSLayoutAttributeCenterYWithinMargins")]
106 pub const CenterYWithinMargins: Self = Self(20);
107 #[doc(alias = "NSLayoutAttributeNotAnAttribute")]
108 pub const NotAnAttribute: Self = Self(0);
109}
110
111unsafe impl Encode for NSLayoutAttribute {
112 const ENCODING: Encoding = NSInteger::ENCODING;
113}
114
115unsafe impl RefEncode for NSLayoutAttribute {
116 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
117}
118
119#[repr(transparent)]
122#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
123pub struct NSLayoutFormatOptions(pub NSUInteger);
124bitflags::bitflags! {
125 impl NSLayoutFormatOptions: NSUInteger {
126 #[doc(alias = "NSLayoutFormatAlignAllLeft")]
127 const AlignAllLeft = 1<<NSLayoutAttribute::Left.0;
128 #[doc(alias = "NSLayoutFormatAlignAllRight")]
129 const AlignAllRight = 1<<NSLayoutAttribute::Right.0;
130 #[doc(alias = "NSLayoutFormatAlignAllTop")]
131 const AlignAllTop = 1<<NSLayoutAttribute::Top.0;
132 #[doc(alias = "NSLayoutFormatAlignAllBottom")]
133 const AlignAllBottom = 1<<NSLayoutAttribute::Bottom.0;
134 #[doc(alias = "NSLayoutFormatAlignAllLeading")]
135 const AlignAllLeading = 1<<NSLayoutAttribute::Leading.0;
136 #[doc(alias = "NSLayoutFormatAlignAllTrailing")]
137 const AlignAllTrailing = 1<<NSLayoutAttribute::Trailing.0;
138 #[doc(alias = "NSLayoutFormatAlignAllCenterX")]
139 const AlignAllCenterX = 1<<NSLayoutAttribute::CenterX.0;
140 #[doc(alias = "NSLayoutFormatAlignAllCenterY")]
141 const AlignAllCenterY = 1<<NSLayoutAttribute::CenterY.0;
142 #[doc(alias = "NSLayoutFormatAlignAllLastBaseline")]
143 const AlignAllLastBaseline = 1<<NSLayoutAttribute::LastBaseline.0;
144 #[doc(alias = "NSLayoutFormatAlignAllFirstBaseline")]
145 const AlignAllFirstBaseline = 1<<NSLayoutAttribute::FirstBaseline.0;
146 #[doc(alias = "NSLayoutFormatAlignAllBaseline")]
147 const AlignAllBaseline = NSLayoutFormatOptions::AlignAllLastBaseline.0;
148 #[doc(alias = "NSLayoutFormatAlignmentMask")]
149 const AlignmentMask = 0xFFFF;
150 #[doc(alias = "NSLayoutFormatDirectionLeadingToTrailing")]
151 const DirectionLeadingToTrailing = 0<<16;
152 #[doc(alias = "NSLayoutFormatDirectionLeftToRight")]
153 const DirectionLeftToRight = 1<<16;
154 #[doc(alias = "NSLayoutFormatDirectionRightToLeft")]
155 const DirectionRightToLeft = 2<<16;
156 #[doc(alias = "NSLayoutFormatDirectionMask")]
157 const DirectionMask = 0x3<<16;
158 #[doc(alias = "NSLayoutFormatSpacingEdgeToEdge")]
159 const SpacingEdgeToEdge = 0<<19;
160 #[doc(alias = "NSLayoutFormatSpacingBaselineToBaseline")]
161 const SpacingBaselineToBaseline = 1<<19;
162 #[doc(alias = "NSLayoutFormatSpacingMask")]
163 const SpacingMask = 0x1<<19;
164 }
165}
166
167unsafe impl Encode for NSLayoutFormatOptions {
168 const ENCODING: Encoding = NSUInteger::ENCODING;
169}
170
171unsafe impl RefEncode for NSLayoutFormatOptions {
172 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
173}
174
175extern_class!(
176 #[unsafe(super(NSObject))]
178 #[thread_kind = MainThreadOnly]
179 #[derive(Debug, PartialEq, Eq, Hash)]
180 pub struct NSLayoutConstraint;
181);
182
183extern_conformance!(
184 unsafe impl NSObjectProtocol for NSLayoutConstraint {}
185);
186
187impl NSLayoutConstraint {
188 extern_methods!(
189 #[unsafe(method(constraintsWithVisualFormat:options:metrics:views:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn constraintsWithVisualFormat_options_metrics_views(
196 format: &NSString,
197 opts: NSLayoutFormatOptions,
198 metrics: Option<&NSDictionary<NSString, AnyObject>>,
199 views: &NSDictionary<NSString, AnyObject>,
200 mtm: MainThreadMarker,
201 ) -> Retained<NSArray<NSLayoutConstraint>>;
202
203 #[cfg(feature = "objc2-core-foundation")]
204 #[unsafe(method(constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(
211 view1: &AnyObject,
212 attr1: NSLayoutAttribute,
213 relation: NSLayoutRelation,
214 view2: Option<&AnyObject>,
215 attr2: NSLayoutAttribute,
216 multiplier: CGFloat,
217 c: CGFloat,
218 mtm: MainThreadMarker,
219 ) -> Retained<Self>;
220
221 #[unsafe(method(priority))]
222 #[unsafe(method_family = none)]
223 pub fn priority(&self) -> UILayoutPriority;
224
225 #[unsafe(method(setPriority:))]
227 #[unsafe(method_family = none)]
228 pub fn setPriority(&self, priority: UILayoutPriority);
229
230 #[unsafe(method(shouldBeArchived))]
231 #[unsafe(method_family = none)]
232 pub fn shouldBeArchived(&self) -> bool;
233
234 #[unsafe(method(setShouldBeArchived:))]
236 #[unsafe(method_family = none)]
237 pub fn setShouldBeArchived(&self, should_be_archived: bool);
238
239 #[unsafe(method(firstItem))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn firstItem(&self) -> Option<Retained<AnyObject>>;
245
246 #[unsafe(method(secondItem))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn secondItem(&self) -> Option<Retained<AnyObject>>;
252
253 #[unsafe(method(firstAttribute))]
254 #[unsafe(method_family = none)]
255 pub fn firstAttribute(&self) -> NSLayoutAttribute;
256
257 #[unsafe(method(secondAttribute))]
258 #[unsafe(method_family = none)]
259 pub fn secondAttribute(&self) -> NSLayoutAttribute;
260
261 #[cfg(feature = "NSLayoutAnchor")]
262 #[unsafe(method(firstAnchor))]
263 #[unsafe(method_family = none)]
264 pub fn firstAnchor(&self) -> Retained<NSLayoutAnchor>;
265
266 #[cfg(feature = "NSLayoutAnchor")]
267 #[unsafe(method(secondAnchor))]
268 #[unsafe(method_family = none)]
269 pub fn secondAnchor(&self) -> Option<Retained<NSLayoutAnchor>>;
270
271 #[unsafe(method(relation))]
272 #[unsafe(method_family = none)]
273 pub fn relation(&self) -> NSLayoutRelation;
274
275 #[cfg(feature = "objc2-core-foundation")]
276 #[unsafe(method(multiplier))]
277 #[unsafe(method_family = none)]
278 pub fn multiplier(&self) -> CGFloat;
279
280 #[cfg(feature = "objc2-core-foundation")]
281 #[unsafe(method(constant))]
282 #[unsafe(method_family = none)]
283 pub fn constant(&self) -> CGFloat;
284
285 #[cfg(feature = "objc2-core-foundation")]
286 #[unsafe(method(setConstant:))]
288 #[unsafe(method_family = none)]
289 pub fn setConstant(&self, constant: CGFloat);
290
291 #[unsafe(method(isActive))]
292 #[unsafe(method_family = none)]
293 pub fn isActive(&self) -> bool;
294
295 #[unsafe(method(setActive:))]
297 #[unsafe(method_family = none)]
298 pub fn setActive(&self, active: bool);
299
300 #[unsafe(method(activateConstraints:))]
301 #[unsafe(method_family = none)]
302 pub fn activateConstraints(
303 constraints: &NSArray<NSLayoutConstraint>,
304 mtm: MainThreadMarker,
305 );
306
307 #[unsafe(method(deactivateConstraints:))]
308 #[unsafe(method_family = none)]
309 pub fn deactivateConstraints(
310 constraints: &NSArray<NSLayoutConstraint>,
311 mtm: MainThreadMarker,
312 );
313 );
314}
315
316impl NSLayoutConstraint {
318 extern_methods!(
319 #[unsafe(method(init))]
320 #[unsafe(method_family = init)]
321 pub fn init(this: Allocated<Self>) -> Retained<Self>;
322
323 #[unsafe(method(new))]
324 #[unsafe(method_family = new)]
325 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
326 );
327}
328
329impl NSLayoutConstraint {
331 extern_methods!(
332 #[unsafe(method(identifier))]
333 #[unsafe(method_family = none)]
334 pub fn identifier(&self) -> Option<Retained<NSString>>;
335
336 #[unsafe(method(setIdentifier:))]
340 #[unsafe(method_family = none)]
341 pub fn setIdentifier(&self, identifier: Option<&NSString>);
342 );
343}
344
345extern_protocol!(
346 pub unsafe trait UILayoutSupport: NSObjectProtocol + MainThreadOnly {
348 #[cfg(feature = "objc2-core-foundation")]
349 #[unsafe(method(length))]
350 #[unsafe(method_family = none)]
351 fn length(&self) -> CGFloat;
352
353 #[cfg(feature = "NSLayoutAnchor")]
354 #[unsafe(method(topAnchor))]
355 #[unsafe(method_family = none)]
356 fn topAnchor(&self) -> Retained<NSLayoutYAxisAnchor>;
357
358 #[cfg(feature = "NSLayoutAnchor")]
359 #[unsafe(method(bottomAnchor))]
360 #[unsafe(method_family = none)]
361 fn bottomAnchor(&self) -> Retained<NSLayoutYAxisAnchor>;
362
363 #[cfg(feature = "NSLayoutAnchor")]
364 #[unsafe(method(heightAnchor))]
365 #[unsafe(method_family = none)]
366 fn heightAnchor(&self) -> Retained<NSLayoutDimension>;
367 }
368);