objc2_quartz_core/generated/
CAConstraintLayoutManager.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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
12/// [Apple's documentation](https://developer.apple.com/documentation/quartzcore/caconstraintattribute?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct CAConstraintAttribute(pub c_int);
17impl CAConstraintAttribute {
18    #[doc(alias = "kCAConstraintMinX")]
19    pub const MinX: Self = Self(0);
20    #[doc(alias = "kCAConstraintMidX")]
21    pub const MidX: Self = Self(1);
22    #[doc(alias = "kCAConstraintMaxX")]
23    pub const MaxX: Self = Self(2);
24    #[doc(alias = "kCAConstraintWidth")]
25    pub const Width: Self = Self(3);
26    #[doc(alias = "kCAConstraintMinY")]
27    pub const MinY: Self = Self(4);
28    #[doc(alias = "kCAConstraintMidY")]
29    pub const MidY: Self = Self(5);
30    #[doc(alias = "kCAConstraintMaxY")]
31    pub const MaxY: Self = Self(6);
32    #[doc(alias = "kCAConstraintHeight")]
33    pub const Height: Self = Self(7);
34}
35
36unsafe impl Encode for CAConstraintAttribute {
37    const ENCODING: Encoding = c_int::ENCODING;
38}
39
40unsafe impl RefEncode for CAConstraintAttribute {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// CAConstraintLayoutManager.
45///
46/// The additions to CALayer for constraint layout. *
47#[cfg(feature = "CALayer")]
48impl CALayer {
49    extern_methods!(
50        #[unsafe(method(constraints))]
51        #[unsafe(method_family = none)]
52        pub fn constraints(&self) -> Option<Retained<NSArray<CAConstraint>>>;
53
54        /// Setter for [`constraints`][Self::constraints].
55        ///
56        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
57        #[unsafe(method(setConstraints:))]
58        #[unsafe(method_family = none)]
59        pub fn setConstraints(&self, constraints: Option<&NSArray<CAConstraint>>);
60
61        #[unsafe(method(addConstraint:))]
62        #[unsafe(method_family = none)]
63        pub fn addConstraint(&self, c: &CAConstraint);
64    );
65}
66
67extern_class!(
68    /// The constraint-based layout manager. *
69    ///
70    /// See also [Apple's documentation](https://developer.apple.com/documentation/quartzcore/caconstraintlayoutmanager?language=objc)
71    #[unsafe(super(NSObject))]
72    #[derive(Debug, PartialEq, Eq, Hash)]
73    pub struct CAConstraintLayoutManager;
74);
75
76#[cfg(feature = "CALayer")]
77extern_conformance!(
78    unsafe impl CALayoutManager for CAConstraintLayoutManager {}
79);
80
81extern_conformance!(
82    unsafe impl NSObjectProtocol for CAConstraintLayoutManager {}
83);
84
85impl CAConstraintLayoutManager {
86    extern_methods!(
87        #[unsafe(method(layoutManager))]
88        #[unsafe(method_family = none)]
89        pub fn layoutManager() -> Retained<Self>;
90    );
91}
92
93/// Methods declared on superclass `NSObject`.
94impl CAConstraintLayoutManager {
95    extern_methods!(
96        #[unsafe(method(init))]
97        #[unsafe(method_family = init)]
98        pub fn init(this: Allocated<Self>) -> Retained<Self>;
99
100        #[unsafe(method(new))]
101        #[unsafe(method_family = new)]
102        pub fn new() -> Retained<Self>;
103    );
104}
105
106impl DefaultRetained for CAConstraintLayoutManager {
107    #[inline]
108    fn default_retained() -> Retained<Self> {
109        Self::new()
110    }
111}
112
113extern_class!(
114    /// The class representing a single layout constraint. *
115    ///
116    /// See also [Apple's documentation](https://developer.apple.com/documentation/quartzcore/caconstraint?language=objc)
117    #[unsafe(super(NSObject))]
118    #[derive(Debug, PartialEq, Eq, Hash)]
119    pub struct CAConstraint;
120);
121
122extern_conformance!(
123    unsafe impl NSCoding for CAConstraint {}
124);
125
126extern_conformance!(
127    unsafe impl NSObjectProtocol for CAConstraint {}
128);
129
130extern_conformance!(
131    unsafe impl NSSecureCoding for CAConstraint {}
132);
133
134impl CAConstraint {
135    extern_methods!(
136        #[cfg(feature = "objc2-core-foundation")]
137        #[unsafe(method(constraintWithAttribute:relativeTo:attribute:scale:offset:))]
138        #[unsafe(method_family = none)]
139        pub fn constraintWithAttribute_relativeTo_attribute_scale_offset(
140            attr: CAConstraintAttribute,
141            src_id: &NSString,
142            src_attr: CAConstraintAttribute,
143            m: CGFloat,
144            c: CGFloat,
145        ) -> Retained<Self>;
146
147        #[cfg(feature = "objc2-core-foundation")]
148        #[unsafe(method(constraintWithAttribute:relativeTo:attribute:offset:))]
149        #[unsafe(method_family = none)]
150        pub fn constraintWithAttribute_relativeTo_attribute_offset(
151            attr: CAConstraintAttribute,
152            src_id: &NSString,
153            src_attr: CAConstraintAttribute,
154            c: CGFloat,
155        ) -> Retained<Self>;
156
157        #[unsafe(method(constraintWithAttribute:relativeTo:attribute:))]
158        #[unsafe(method_family = none)]
159        pub fn constraintWithAttribute_relativeTo_attribute(
160            attr: CAConstraintAttribute,
161            src_id: &NSString,
162            src_attr: CAConstraintAttribute,
163        ) -> Retained<Self>;
164
165        #[cfg(feature = "objc2-core-foundation")]
166        #[unsafe(method(initWithAttribute:relativeTo:attribute:scale:offset:))]
167        #[unsafe(method_family = init)]
168        pub fn initWithAttribute_relativeTo_attribute_scale_offset(
169            this: Allocated<Self>,
170            attr: CAConstraintAttribute,
171            src_id: &NSString,
172            src_attr: CAConstraintAttribute,
173            m: CGFloat,
174            c: CGFloat,
175        ) -> Retained<Self>;
176
177        #[unsafe(method(attribute))]
178        #[unsafe(method_family = none)]
179        pub fn attribute(&self) -> CAConstraintAttribute;
180
181        #[unsafe(method(sourceName))]
182        #[unsafe(method_family = none)]
183        pub fn sourceName(&self) -> Retained<NSString>;
184
185        #[unsafe(method(sourceAttribute))]
186        #[unsafe(method_family = none)]
187        pub fn sourceAttribute(&self) -> CAConstraintAttribute;
188
189        #[cfg(feature = "objc2-core-foundation")]
190        #[unsafe(method(scale))]
191        #[unsafe(method_family = none)]
192        pub fn scale(&self) -> CGFloat;
193
194        #[cfg(feature = "objc2-core-foundation")]
195        #[unsafe(method(offset))]
196        #[unsafe(method_family = none)]
197        pub fn offset(&self) -> CGFloat;
198    );
199}
200
201/// Methods declared on superclass `NSObject`.
202impl CAConstraint {
203    extern_methods!(
204        #[unsafe(method(init))]
205        #[unsafe(method_family = init)]
206        pub fn init(this: Allocated<Self>) -> Retained<Self>;
207
208        #[unsafe(method(new))]
209        #[unsafe(method_family = new)]
210        pub fn new() -> Retained<Self>;
211    );
212}
213
214impl DefaultRetained for CAConstraint {
215    #[inline]
216    fn default_retained() -> Retained<Self> {
217        Self::new()
218    }
219}