objc2_ui_kit/generated/
UICollectionViewFlowLayout.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
12extern "C" {
13    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewflowlayoutautomaticsize?language=objc)
14    #[cfg(feature = "objc2-core-foundation")]
15    pub static UICollectionViewFlowLayoutAutomaticSize: CGSize;
16}
17
18/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewflowlayoutsectioninsetreference?language=objc)
19// NS_ENUM
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct UICollectionViewFlowLayoutSectionInsetReference(pub NSInteger);
23impl UICollectionViewFlowLayoutSectionInsetReference {
24    #[doc(alias = "UICollectionViewFlowLayoutSectionInsetFromContentInset")]
25    pub const FromContentInset: Self = Self(0);
26    #[doc(alias = "UICollectionViewFlowLayoutSectionInsetFromSafeArea")]
27    pub const FromSafeArea: Self = Self(1);
28    #[doc(alias = "UICollectionViewFlowLayoutSectionInsetFromLayoutMargins")]
29    pub const FromLayoutMargins: Self = Self(2);
30}
31
32unsafe impl Encode for UICollectionViewFlowLayoutSectionInsetReference {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for UICollectionViewFlowLayoutSectionInsetReference {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewflowlayoutinvalidationcontext?language=objc)
42    #[unsafe(super(UICollectionViewLayoutInvalidationContext, NSObject))]
43    #[thread_kind = MainThreadOnly]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    #[cfg(feature = "UICollectionViewLayout")]
46    pub struct UICollectionViewFlowLayoutInvalidationContext;
47);
48
49#[cfg(feature = "UICollectionViewLayout")]
50extern_conformance!(
51    unsafe impl NSObjectProtocol for UICollectionViewFlowLayoutInvalidationContext {}
52);
53
54#[cfg(feature = "UICollectionViewLayout")]
55impl UICollectionViewFlowLayoutInvalidationContext {
56    extern_methods!(
57        #[unsafe(method(invalidateFlowLayoutDelegateMetrics))]
58        #[unsafe(method_family = none)]
59        pub fn invalidateFlowLayoutDelegateMetrics(&self) -> bool;
60
61        /// Setter for [`invalidateFlowLayoutDelegateMetrics`][Self::invalidateFlowLayoutDelegateMetrics].
62        #[unsafe(method(setInvalidateFlowLayoutDelegateMetrics:))]
63        #[unsafe(method_family = none)]
64        pub fn setInvalidateFlowLayoutDelegateMetrics(
65            &self,
66            invalidate_flow_layout_delegate_metrics: bool,
67        );
68
69        #[unsafe(method(invalidateFlowLayoutAttributes))]
70        #[unsafe(method_family = none)]
71        pub fn invalidateFlowLayoutAttributes(&self) -> bool;
72
73        /// Setter for [`invalidateFlowLayoutAttributes`][Self::invalidateFlowLayoutAttributes].
74        #[unsafe(method(setInvalidateFlowLayoutAttributes:))]
75        #[unsafe(method_family = none)]
76        pub fn setInvalidateFlowLayoutAttributes(&self, invalidate_flow_layout_attributes: bool);
77    );
78}
79
80/// Methods declared on superclass `NSObject`.
81#[cfg(feature = "UICollectionViewLayout")]
82impl UICollectionViewFlowLayoutInvalidationContext {
83    extern_methods!(
84        #[unsafe(method(init))]
85        #[unsafe(method_family = init)]
86        pub fn init(this: Allocated<Self>) -> Retained<Self>;
87
88        #[unsafe(method(new))]
89        #[unsafe(method_family = new)]
90        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
91    );
92}
93
94extern_protocol!(
95    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewdelegateflowlayout?language=objc)
96    #[cfg(all(feature = "UICollectionView", feature = "UIScrollView"))]
97    pub unsafe trait UICollectionViewDelegateFlowLayout:
98        UICollectionViewDelegate + MainThreadOnly
99    {
100        #[cfg(all(
101            feature = "UICollectionViewLayout",
102            feature = "UIResponder",
103            feature = "UIView",
104            feature = "objc2-core-foundation"
105        ))]
106        #[optional]
107        #[unsafe(method(collectionView:layout:sizeForItemAtIndexPath:))]
108        #[unsafe(method_family = none)]
109        fn collectionView_layout_sizeForItemAtIndexPath(
110            &self,
111            collection_view: &UICollectionView,
112            collection_view_layout: &UICollectionViewLayout,
113            index_path: &NSIndexPath,
114        ) -> CGSize;
115
116        #[cfg(all(
117            feature = "UICollectionViewLayout",
118            feature = "UIGeometry",
119            feature = "UIResponder",
120            feature = "UIView",
121            feature = "objc2-core-foundation"
122        ))]
123        #[optional]
124        #[unsafe(method(collectionView:layout:insetForSectionAtIndex:))]
125        #[unsafe(method_family = none)]
126        fn collectionView_layout_insetForSectionAtIndex(
127            &self,
128            collection_view: &UICollectionView,
129            collection_view_layout: &UICollectionViewLayout,
130            section: NSInteger,
131        ) -> UIEdgeInsets;
132
133        #[cfg(all(
134            feature = "UICollectionViewLayout",
135            feature = "UIResponder",
136            feature = "UIView",
137            feature = "objc2-core-foundation"
138        ))]
139        #[optional]
140        #[unsafe(method(collectionView:layout:minimumLineSpacingForSectionAtIndex:))]
141        #[unsafe(method_family = none)]
142        fn collectionView_layout_minimumLineSpacingForSectionAtIndex(
143            &self,
144            collection_view: &UICollectionView,
145            collection_view_layout: &UICollectionViewLayout,
146            section: NSInteger,
147        ) -> CGFloat;
148
149        #[cfg(all(
150            feature = "UICollectionViewLayout",
151            feature = "UIResponder",
152            feature = "UIView",
153            feature = "objc2-core-foundation"
154        ))]
155        #[optional]
156        #[unsafe(method(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:))]
157        #[unsafe(method_family = none)]
158        fn collectionView_layout_minimumInteritemSpacingForSectionAtIndex(
159            &self,
160            collection_view: &UICollectionView,
161            collection_view_layout: &UICollectionViewLayout,
162            section: NSInteger,
163        ) -> CGFloat;
164
165        #[cfg(all(
166            feature = "UICollectionViewLayout",
167            feature = "UIResponder",
168            feature = "UIView",
169            feature = "objc2-core-foundation"
170        ))]
171        #[optional]
172        #[unsafe(method(collectionView:layout:referenceSizeForHeaderInSection:))]
173        #[unsafe(method_family = none)]
174        fn collectionView_layout_referenceSizeForHeaderInSection(
175            &self,
176            collection_view: &UICollectionView,
177            collection_view_layout: &UICollectionViewLayout,
178            section: NSInteger,
179        ) -> CGSize;
180
181        #[cfg(all(
182            feature = "UICollectionViewLayout",
183            feature = "UIResponder",
184            feature = "UIView",
185            feature = "objc2-core-foundation"
186        ))]
187        #[optional]
188        #[unsafe(method(collectionView:layout:referenceSizeForFooterInSection:))]
189        #[unsafe(method_family = none)]
190        fn collectionView_layout_referenceSizeForFooterInSection(
191            &self,
192            collection_view: &UICollectionView,
193            collection_view_layout: &UICollectionViewLayout,
194            section: NSInteger,
195        ) -> CGSize;
196    }
197);
198
199extern_class!(
200    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicollectionviewflowlayout?language=objc)
201    #[unsafe(super(UICollectionViewLayout, NSObject))]
202    #[thread_kind = MainThreadOnly]
203    #[derive(Debug, PartialEq, Eq, Hash)]
204    #[cfg(feature = "UICollectionViewLayout")]
205    pub struct UICollectionViewFlowLayout;
206);
207
208#[cfg(feature = "UICollectionViewLayout")]
209extern_conformance!(
210    unsafe impl NSCoding for UICollectionViewFlowLayout {}
211);
212
213#[cfg(feature = "UICollectionViewLayout")]
214extern_conformance!(
215    unsafe impl NSObjectProtocol for UICollectionViewFlowLayout {}
216);
217
218#[cfg(feature = "UICollectionViewLayout")]
219impl UICollectionViewFlowLayout {
220    extern_methods!(
221        #[cfg(feature = "objc2-core-foundation")]
222        #[unsafe(method(minimumLineSpacing))]
223        #[unsafe(method_family = none)]
224        pub fn minimumLineSpacing(&self) -> CGFloat;
225
226        #[cfg(feature = "objc2-core-foundation")]
227        /// Setter for [`minimumLineSpacing`][Self::minimumLineSpacing].
228        #[unsafe(method(setMinimumLineSpacing:))]
229        #[unsafe(method_family = none)]
230        pub fn setMinimumLineSpacing(&self, minimum_line_spacing: CGFloat);
231
232        #[cfg(feature = "objc2-core-foundation")]
233        #[unsafe(method(minimumInteritemSpacing))]
234        #[unsafe(method_family = none)]
235        pub fn minimumInteritemSpacing(&self) -> CGFloat;
236
237        #[cfg(feature = "objc2-core-foundation")]
238        /// Setter for [`minimumInteritemSpacing`][Self::minimumInteritemSpacing].
239        #[unsafe(method(setMinimumInteritemSpacing:))]
240        #[unsafe(method_family = none)]
241        pub fn setMinimumInteritemSpacing(&self, minimum_interitem_spacing: CGFloat);
242
243        #[cfg(feature = "objc2-core-foundation")]
244        #[unsafe(method(itemSize))]
245        #[unsafe(method_family = none)]
246        pub fn itemSize(&self) -> CGSize;
247
248        #[cfg(feature = "objc2-core-foundation")]
249        /// Setter for [`itemSize`][Self::itemSize].
250        #[unsafe(method(setItemSize:))]
251        #[unsafe(method_family = none)]
252        pub fn setItemSize(&self, item_size: CGSize);
253
254        #[cfg(feature = "objc2-core-foundation")]
255        #[unsafe(method(estimatedItemSize))]
256        #[unsafe(method_family = none)]
257        pub fn estimatedItemSize(&self) -> CGSize;
258
259        #[cfg(feature = "objc2-core-foundation")]
260        /// Setter for [`estimatedItemSize`][Self::estimatedItemSize].
261        #[unsafe(method(setEstimatedItemSize:))]
262        #[unsafe(method_family = none)]
263        pub fn setEstimatedItemSize(&self, estimated_item_size: CGSize);
264
265        #[unsafe(method(scrollDirection))]
266        #[unsafe(method_family = none)]
267        pub fn scrollDirection(&self) -> UICollectionViewScrollDirection;
268
269        /// Setter for [`scrollDirection`][Self::scrollDirection].
270        #[unsafe(method(setScrollDirection:))]
271        #[unsafe(method_family = none)]
272        pub fn setScrollDirection(&self, scroll_direction: UICollectionViewScrollDirection);
273
274        #[cfg(feature = "objc2-core-foundation")]
275        #[unsafe(method(headerReferenceSize))]
276        #[unsafe(method_family = none)]
277        pub fn headerReferenceSize(&self) -> CGSize;
278
279        #[cfg(feature = "objc2-core-foundation")]
280        /// Setter for [`headerReferenceSize`][Self::headerReferenceSize].
281        #[unsafe(method(setHeaderReferenceSize:))]
282        #[unsafe(method_family = none)]
283        pub fn setHeaderReferenceSize(&self, header_reference_size: CGSize);
284
285        #[cfg(feature = "objc2-core-foundation")]
286        #[unsafe(method(footerReferenceSize))]
287        #[unsafe(method_family = none)]
288        pub fn footerReferenceSize(&self) -> CGSize;
289
290        #[cfg(feature = "objc2-core-foundation")]
291        /// Setter for [`footerReferenceSize`][Self::footerReferenceSize].
292        #[unsafe(method(setFooterReferenceSize:))]
293        #[unsafe(method_family = none)]
294        pub fn setFooterReferenceSize(&self, footer_reference_size: CGSize);
295
296        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
297        #[unsafe(method(sectionInset))]
298        #[unsafe(method_family = none)]
299        pub fn sectionInset(&self) -> UIEdgeInsets;
300
301        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
302        /// Setter for [`sectionInset`][Self::sectionInset].
303        #[unsafe(method(setSectionInset:))]
304        #[unsafe(method_family = none)]
305        pub fn setSectionInset(&self, section_inset: UIEdgeInsets);
306
307        /// The reference boundary that the section insets will be defined as relative to. Defaults to `.fromContentInset`.
308        /// NOTE: Content inset will always be respected at a minimum. For example, if the sectionInsetReference equals `.fromSafeArea`, but the adjusted content inset is greater that the combination of the safe area and section insets, then section content will be aligned with the content inset instead.
309        #[unsafe(method(sectionInsetReference))]
310        #[unsafe(method_family = none)]
311        pub fn sectionInsetReference(&self) -> UICollectionViewFlowLayoutSectionInsetReference;
312
313        /// Setter for [`sectionInsetReference`][Self::sectionInsetReference].
314        #[unsafe(method(setSectionInsetReference:))]
315        #[unsafe(method_family = none)]
316        pub fn setSectionInsetReference(
317            &self,
318            section_inset_reference: UICollectionViewFlowLayoutSectionInsetReference,
319        );
320
321        #[unsafe(method(sectionHeadersPinToVisibleBounds))]
322        #[unsafe(method_family = none)]
323        pub fn sectionHeadersPinToVisibleBounds(&self) -> bool;
324
325        /// Setter for [`sectionHeadersPinToVisibleBounds`][Self::sectionHeadersPinToVisibleBounds].
326        #[unsafe(method(setSectionHeadersPinToVisibleBounds:))]
327        #[unsafe(method_family = none)]
328        pub fn setSectionHeadersPinToVisibleBounds(
329            &self,
330            section_headers_pin_to_visible_bounds: bool,
331        );
332
333        #[unsafe(method(sectionFootersPinToVisibleBounds))]
334        #[unsafe(method_family = none)]
335        pub fn sectionFootersPinToVisibleBounds(&self) -> bool;
336
337        /// Setter for [`sectionFootersPinToVisibleBounds`][Self::sectionFootersPinToVisibleBounds].
338        #[unsafe(method(setSectionFootersPinToVisibleBounds:))]
339        #[unsafe(method_family = none)]
340        pub fn setSectionFootersPinToVisibleBounds(
341            &self,
342            section_footers_pin_to_visible_bounds: bool,
343        );
344    );
345}
346
347/// Methods declared on superclass `UICollectionViewLayout`.
348#[cfg(feature = "UICollectionViewLayout")]
349impl UICollectionViewFlowLayout {
350    extern_methods!(
351        #[unsafe(method(init))]
352        #[unsafe(method_family = init)]
353        pub fn init(this: Allocated<Self>) -> Retained<Self>;
354
355        /// # Safety
356        ///
357        /// `coder` possibly has further requirements.
358        #[unsafe(method(initWithCoder:))]
359        #[unsafe(method_family = init)]
360        pub unsafe fn initWithCoder(
361            this: Allocated<Self>,
362            coder: &NSCoder,
363        ) -> Option<Retained<Self>>;
364    );
365}
366
367/// Methods declared on superclass `NSObject`.
368#[cfg(feature = "UICollectionViewLayout")]
369impl UICollectionViewFlowLayout {
370    extern_methods!(
371        #[unsafe(method(new))]
372        #[unsafe(method_family = new)]
373        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
374    );
375}