objc2_ui_kit/generated/
UIAttachmentBehavior.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/uikit/uiattachmentbehaviortype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIAttachmentBehaviorType(pub NSInteger);
17impl UIAttachmentBehaviorType {
18    #[doc(alias = "UIAttachmentBehaviorTypeItems")]
19    pub const Items: Self = Self(0);
20    #[doc(alias = "UIAttachmentBehaviorTypeAnchor")]
21    pub const Anchor: Self = Self(1);
22}
23
24unsafe impl Encode for UIAttachmentBehaviorType {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for UIAttachmentBehaviorType {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uifloatrange?language=objc)
33#[cfg(feature = "objc2-core-foundation")]
34#[repr(C)]
35#[derive(Clone, Copy, Debug, PartialEq)]
36pub struct UIFloatRange {
37    pub minimum: CGFloat,
38    pub maximum: CGFloat,
39}
40
41#[cfg(feature = "objc2-core-foundation")]
42unsafe impl Encode for UIFloatRange {
43    const ENCODING: Encoding = Encoding::Struct("?", &[<CGFloat>::ENCODING, <CGFloat>::ENCODING]);
44}
45
46#[cfg(feature = "objc2-core-foundation")]
47unsafe impl RefEncode for UIFloatRange {
48    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
49}
50
51#[cfg(feature = "objc2-core-foundation")]
52unsafe impl Send for UIFloatRange {}
53
54#[cfg(feature = "objc2-core-foundation")]
55unsafe impl Sync for UIFloatRange {}
56
57extern "C" {
58    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uifloatrangezero?language=objc)
59    #[cfg(feature = "objc2-core-foundation")]
60    pub static UIFloatRangeZero: UIFloatRange;
61}
62
63extern "C" {
64    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uifloatrangeinfinite?language=objc)
65    #[cfg(feature = "objc2-core-foundation")]
66    pub static UIFloatRangeInfinite: UIFloatRange;
67}
68
69#[cfg(feature = "objc2-core-foundation")]
70#[inline]
71pub unsafe extern "C-unwind" fn UIFloatRangeIsInfinite(range: UIFloatRange) -> bool {
72    extern "C-unwind" {
73        fn UIFloatRangeIsInfinite(range: UIFloatRange) -> Bool;
74    }
75    unsafe { UIFloatRangeIsInfinite(range) }.as_bool()
76}
77
78// TODO: pub fn UIFloatRangeMake(minimum: CGFloat,maximum: CGFloat,) -> UIFloatRange;
79
80// TODO: pub fn UIFloatRangeIsEqualToRange(range: UIFloatRange,other_range: UIFloatRange,) -> Bool;
81
82extern_class!(
83    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiattachmentbehavior?language=objc)
84    #[unsafe(super(UIDynamicBehavior, NSObject))]
85    #[thread_kind = MainThreadOnly]
86    #[derive(Debug, PartialEq, Eq, Hash)]
87    #[cfg(feature = "UIDynamicBehavior")]
88    pub struct UIAttachmentBehavior;
89);
90
91#[cfg(feature = "UIDynamicBehavior")]
92unsafe impl NSObjectProtocol for UIAttachmentBehavior {}
93
94#[cfg(feature = "UIDynamicBehavior")]
95impl UIAttachmentBehavior {
96    extern_methods!(
97        #[cfg(feature = "objc2-core-foundation")]
98        #[unsafe(method(initWithItem:attachedToAnchor:))]
99        #[unsafe(method_family = init)]
100        pub unsafe fn initWithItem_attachedToAnchor(
101            this: Allocated<Self>,
102            item: &ProtocolObject<dyn UIDynamicItem>,
103            point: CGPoint,
104        ) -> Retained<Self>;
105
106        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
107        #[unsafe(method(initWithItem:offsetFromCenter:attachedToAnchor:))]
108        #[unsafe(method_family = init)]
109        pub unsafe fn initWithItem_offsetFromCenter_attachedToAnchor(
110            this: Allocated<Self>,
111            item: &ProtocolObject<dyn UIDynamicItem>,
112            offset: UIOffset,
113            point: CGPoint,
114        ) -> Retained<Self>;
115
116        #[unsafe(method(initWithItem:attachedToItem:))]
117        #[unsafe(method_family = init)]
118        pub unsafe fn initWithItem_attachedToItem(
119            this: Allocated<Self>,
120            item1: &ProtocolObject<dyn UIDynamicItem>,
121            item2: &ProtocolObject<dyn UIDynamicItem>,
122        ) -> Retained<Self>;
123
124        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
125        #[unsafe(method(initWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithItem_offsetFromCenter_attachedToItem_offsetFromCenter(
128            this: Allocated<Self>,
129            item1: &ProtocolObject<dyn UIDynamicItem>,
130            offset1: UIOffset,
131            item2: &ProtocolObject<dyn UIDynamicItem>,
132            offset2: UIOffset,
133        ) -> Retained<Self>;
134
135        #[cfg(feature = "objc2-core-foundation")]
136        /// A sliding attachment allows for relative translation of two items along a specified axis with respect to the anchor point. A sliding
137        /// attachment prevents all relative rotation of the dynamic items.
138        ///
139        /// Parameter `item1`: The first of two dynamic items connected by the attachment behavior.
140        ///
141        /// Parameter `item2`: The second of two dynamic items connected by the attachment behavior.
142        ///
143        /// Parameter `point`: The point for which each item will be attached. The anchor point will be converted to each items local coordinate system.
144        ///
145        /// Parameter `axis`: Axis of allowed relative translation between local anchor point. Must be a unit vector.
146        ///
147        /// See: attachmentRange, Represents the slidable range of the attachment with respect to the anchor point along the specified axis, this range must include 0
148        #[unsafe(method(slidingAttachmentWithItem:attachedToItem:attachmentAnchor:axisOfTranslation:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn slidingAttachmentWithItem_attachedToItem_attachmentAnchor_axisOfTranslation(
151            item1: &ProtocolObject<dyn UIDynamicItem>,
152            item2: &ProtocolObject<dyn UIDynamicItem>,
153            point: CGPoint,
154            axis: CGVector,
155        ) -> Retained<Self>;
156
157        #[cfg(feature = "objc2-core-foundation")]
158        /// A sliding attachment allows for translation of the item along a specified axis with respect to the anchor point. A sliding
159        /// attachment prevents all relative rotation of the dynamic items.
160        ///
161        /// Parameter `item1`: The dynamic item connected by the attachment behavior.
162        ///
163        /// Parameter `point`: The point for the item will be anchored by the attachment.
164        ///
165        /// Parameter `axis`: Axis of allowed translation for the item. Must be a unit vector.
166        ///
167        /// See: attachmentRange, Represents the slidable range of the attachment with respect to the anchor point along the specified axis, this range must include 0
168        #[unsafe(method(slidingAttachmentWithItem:attachmentAnchor:axisOfTranslation:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn slidingAttachmentWithItem_attachmentAnchor_axisOfTranslation(
171            item: &ProtocolObject<dyn UIDynamicItem>,
172            point: CGPoint,
173            axis: CGVector,
174        ) -> Retained<Self>;
175
176        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
177        /// A limit attachment imposes a maximum distance between two dynamic items, as if they were connected by a rope.
178        ///
179        /// Parameter `item1`: The first of two dynamic items connected by the attachment behavior.
180        ///
181        /// Parameter `offset1`: The point, within the dynamic item and described as an offset from its center point, for the attachment behavior.
182        ///
183        /// Parameter `item2`: The second of two dynamic items connected by the attachment behavior.
184        ///
185        /// Parameter `offset2`: The point, within the dynamic item and described as an offset from its center point, for the attachment behavior.
186        ///
187        /// See: length
188        #[unsafe(method(limitAttachmentWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn limitAttachmentWithItem_offsetFromCenter_attachedToItem_offsetFromCenter(
191            item1: &ProtocolObject<dyn UIDynamicItem>,
192            offset1: UIOffset,
193            item2: &ProtocolObject<dyn UIDynamicItem>,
194            offset2: UIOffset,
195        ) -> Retained<Self>;
196
197        #[cfg(feature = "objc2-core-foundation")]
198        /// A fixed attachment fuses two dynamic items together at a reference point.
199        /// Fixed attachments are useful for creating complex shapes that can be broken apart later.
200        ///
201        /// Parameter `item1`: The first of two dynamic items connected by the attachment behavior.
202        ///
203        /// Parameter `item2`: The second of two dynamic items connected by the attachment behavior.
204        ///
205        /// Parameter `point`: The point for which each item will be attached. The anchor point will be converted to each items local coordinate system.
206        #[unsafe(method(fixedAttachmentWithItem:attachedToItem:attachmentAnchor:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn fixedAttachmentWithItem_attachedToItem_attachmentAnchor(
209            item1: &ProtocolObject<dyn UIDynamicItem>,
210            item2: &ProtocolObject<dyn UIDynamicItem>,
211            point: CGPoint,
212        ) -> Retained<Self>;
213
214        #[cfg(feature = "objc2-core-foundation")]
215        /// A pin attachment allows two dynamic items to independently rotate around the anchor point as if pinned together.
216        /// You can configure how far the two objects may rotate and the resistance to rotation
217        ///
218        /// Parameter `item1`: The first of two dynamic items connected by the attachment behavior.
219        ///
220        /// Parameter `item2`: The second of two dynamic items connected by the attachment behavior.
221        ///
222        /// Parameter `point`: The point for which each item will be attached. The anchor point will be converted to each items local coordinate system
223        ///
224        /// See: frictionTorque, resistance to rotation
225        #[unsafe(method(pinAttachmentWithItem:attachedToItem:attachmentAnchor:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn pinAttachmentWithItem_attachedToItem_attachmentAnchor(
228            item1: &ProtocolObject<dyn UIDynamicItem>,
229            item2: &ProtocolObject<dyn UIDynamicItem>,
230            point: CGPoint,
231        ) -> Retained<Self>;
232
233        #[unsafe(method(items))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
236
237        #[unsafe(method(attachedBehaviorType))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn attachedBehaviorType(&self) -> UIAttachmentBehaviorType;
240
241        #[cfg(feature = "objc2-core-foundation")]
242        #[unsafe(method(anchorPoint))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn anchorPoint(&self) -> CGPoint;
245
246        #[cfg(feature = "objc2-core-foundation")]
247        /// Setter for [`anchorPoint`][Self::anchorPoint].
248        #[unsafe(method(setAnchorPoint:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);
251
252        #[cfg(feature = "objc2-core-foundation")]
253        #[unsafe(method(length))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn length(&self) -> CGFloat;
256
257        #[cfg(feature = "objc2-core-foundation")]
258        /// Setter for [`length`][Self::length].
259        #[unsafe(method(setLength:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn setLength(&self, length: CGFloat);
262
263        #[cfg(feature = "objc2-core-foundation")]
264        #[unsafe(method(damping))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn damping(&self) -> CGFloat;
267
268        #[cfg(feature = "objc2-core-foundation")]
269        /// Setter for [`damping`][Self::damping].
270        #[unsafe(method(setDamping:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setDamping(&self, damping: CGFloat);
273
274        #[cfg(feature = "objc2-core-foundation")]
275        #[unsafe(method(frequency))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn frequency(&self) -> CGFloat;
278
279        #[cfg(feature = "objc2-core-foundation")]
280        /// Setter for [`frequency`][Self::frequency].
281        #[unsafe(method(setFrequency:))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn setFrequency(&self, frequency: CGFloat);
284
285        #[cfg(feature = "objc2-core-foundation")]
286        #[unsafe(method(frictionTorque))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn frictionTorque(&self) -> CGFloat;
289
290        #[cfg(feature = "objc2-core-foundation")]
291        /// Setter for [`frictionTorque`][Self::frictionTorque].
292        #[unsafe(method(setFrictionTorque:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setFrictionTorque(&self, friction_torque: CGFloat);
295
296        #[cfg(feature = "objc2-core-foundation")]
297        #[unsafe(method(attachmentRange))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn attachmentRange(&self) -> UIFloatRange;
300
301        #[cfg(feature = "objc2-core-foundation")]
302        /// Setter for [`attachmentRange`][Self::attachmentRange].
303        #[unsafe(method(setAttachmentRange:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setAttachmentRange(&self, attachment_range: UIFloatRange);
306    );
307}
308
309/// Methods declared on superclass `NSObject`.
310#[cfg(feature = "UIDynamicBehavior")]
311impl UIAttachmentBehavior {
312    extern_methods!(
313        #[unsafe(method(init))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
316
317        #[unsafe(method(new))]
318        #[unsafe(method_family = new)]
319        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
320    );
321}