1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIAttachmentBehaviorType(pub NSInteger);
impl UIAttachmentBehaviorType {
    #[doc(alias = "UIAttachmentBehaviorTypeItems")]
    pub const Items: Self = Self(0);
    #[doc(alias = "UIAttachmentBehaviorTypeAnchor")]
    pub const Anchor: Self = Self(1);
}

unsafe impl Encode for UIAttachmentBehaviorType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIAttachmentBehaviorType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct UIFloatRange {
    pub minimum: CGFloat,
    pub maximum: CGFloat,
}

unsafe impl Encode for UIFloatRange {
    const ENCODING: Encoding = Encoding::Struct("?", &[<CGFloat>::ENCODING, <CGFloat>::ENCODING]);
}

unsafe impl RefEncode for UIFloatRange {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

unsafe impl Send for UIFloatRange {}

unsafe impl Sync for UIFloatRange {}

extern "C" {
    pub static UIFloatRangeZero: UIFloatRange;
}

extern "C" {
    pub static UIFloatRangeInfinite: UIFloatRange;
}

extern "C" {
    pub fn UIFloatRangeIsInfinite(range: UIFloatRange) -> Bool;
}

// TODO: pub fn UIFloatRangeMake(minimum: CGFloat,maximum: CGFloat,) -> UIFloatRange;

// TODO: pub fn UIFloatRangeIsEqualToRange(range: UIFloatRange,other_range: UIFloatRange,) -> Bool;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIDynamicBehavior")]
    pub struct UIAttachmentBehavior;

    #[cfg(feature = "UIDynamicBehavior")]
    unsafe impl ClassType for UIAttachmentBehavior {
        #[inherits(NSObject)]
        type Super = UIDynamicBehavior;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(feature = "UIDynamicBehavior")]
unsafe impl NSObjectProtocol for UIAttachmentBehavior {}

extern_methods!(
    #[cfg(feature = "UIDynamicBehavior")]
    unsafe impl UIAttachmentBehavior {
        #[method_id(@__retain_semantics Init initWithItem:attachedToAnchor:)]
        pub unsafe fn initWithItem_attachedToAnchor(
            this: Allocated<Self>,
            item: &ProtocolObject<dyn UIDynamicItem>,
            point: CGPoint,
        ) -> Retained<Self>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Init initWithItem:offsetFromCenter:attachedToAnchor:)]
        pub unsafe fn initWithItem_offsetFromCenter_attachedToAnchor(
            this: Allocated<Self>,
            item: &ProtocolObject<dyn UIDynamicItem>,
            offset: UIOffset,
            point: CGPoint,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithItem:attachedToItem:)]
        pub unsafe fn initWithItem_attachedToItem(
            this: Allocated<Self>,
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
        ) -> Retained<Self>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Init initWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:)]
        pub unsafe fn initWithItem_offsetFromCenter_attachedToItem_offsetFromCenter(
            this: Allocated<Self>,
            item1: &ProtocolObject<dyn UIDynamicItem>,
            offset1: UIOffset,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            offset2: UIOffset,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other slidingAttachmentWithItem:attachedToItem:attachmentAnchor:axisOfTranslation:)]
        pub unsafe fn slidingAttachmentWithItem_attachedToItem_attachmentAnchor_axisOfTranslation(
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            point: CGPoint,
            axis: CGVector,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other slidingAttachmentWithItem:attachmentAnchor:axisOfTranslation:)]
        pub unsafe fn slidingAttachmentWithItem_attachmentAnchor_axisOfTranslation(
            item: &ProtocolObject<dyn UIDynamicItem>,
            point: CGPoint,
            axis: CGVector,
        ) -> Retained<Self>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other limitAttachmentWithItem:offsetFromCenter:attachedToItem:offsetFromCenter:)]
        pub unsafe fn limitAttachmentWithItem_offsetFromCenter_attachedToItem_offsetFromCenter(
            item1: &ProtocolObject<dyn UIDynamicItem>,
            offset1: UIOffset,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            offset2: UIOffset,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other fixedAttachmentWithItem:attachedToItem:attachmentAnchor:)]
        pub unsafe fn fixedAttachmentWithItem_attachedToItem_attachmentAnchor(
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            point: CGPoint,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other pinAttachmentWithItem:attachedToItem:attachmentAnchor:)]
        pub unsafe fn pinAttachmentWithItem_attachedToItem_attachmentAnchor(
            item1: &ProtocolObject<dyn UIDynamicItem>,
            item2: &ProtocolObject<dyn UIDynamicItem>,
            point: CGPoint,
        ) -> Retained<Self>;

        #[method_id(@__retain_semantics Other items)]
        pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;

        #[method(attachedBehaviorType)]
        pub unsafe fn attachedBehaviorType(&self) -> UIAttachmentBehaviorType;

        #[method(anchorPoint)]
        pub unsafe fn anchorPoint(&self) -> CGPoint;

        #[method(setAnchorPoint:)]
        pub unsafe fn setAnchorPoint(&self, anchor_point: CGPoint);

        #[method(length)]
        pub unsafe fn length(&self) -> CGFloat;

        #[method(setLength:)]
        pub unsafe fn setLength(&self, length: CGFloat);

        #[method(damping)]
        pub unsafe fn damping(&self) -> CGFloat;

        #[method(setDamping:)]
        pub unsafe fn setDamping(&self, damping: CGFloat);

        #[method(frequency)]
        pub unsafe fn frequency(&self) -> CGFloat;

        #[method(setFrequency:)]
        pub unsafe fn setFrequency(&self, frequency: CGFloat);

        #[method(frictionTorque)]
        pub unsafe fn frictionTorque(&self) -> CGFloat;

        #[method(setFrictionTorque:)]
        pub unsafe fn setFrictionTorque(&self, friction_torque: CGFloat);

        #[method(attachmentRange)]
        pub unsafe fn attachmentRange(&self) -> UIFloatRange;

        #[method(setAttachmentRange:)]
        pub unsafe fn setAttachmentRange(&self, attachment_range: UIFloatRange);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "UIDynamicBehavior")]
    unsafe impl UIAttachmentBehavior {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);