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