objc2_app_kit/generated/
NSScrubberLayout.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_class!(
13    /// `NSScrubberLayoutAttributes`describes the layout of a single
14    /// `NSScrubber`item.
15    ///
16    /// `NSScrubberLayout`objects transact in terms of
17    /// `NSScrubberLayoutAttributes.``NSScrubberLayoutAttributes`can be subclassed if a layout object wants to include more layout information than the base implementation provides. Subclasses of
18    /// `NSScrubberLayoutAttributes`must implement
19    /// `isEqual:,``hash,`and the
20    /// `NSCopying`protocol.
21    ///
22    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscrubberlayoutattributes?language=objc)
23    #[unsafe(super(NSObject))]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    pub struct NSScrubberLayoutAttributes;
26);
27
28extern_conformance!(
29    unsafe impl NSCopying for NSScrubberLayoutAttributes {}
30);
31
32unsafe impl CopyingHelper for NSScrubberLayoutAttributes {
33    type Result = Self;
34}
35
36extern_conformance!(
37    unsafe impl NSObjectProtocol for NSScrubberLayoutAttributes {}
38);
39
40impl NSScrubberLayoutAttributes {
41    extern_methods!(
42        #[unsafe(method(itemIndex))]
43        #[unsafe(method_family = none)]
44        pub fn itemIndex(&self) -> NSInteger;
45
46        /// Setter for [`itemIndex`][Self::itemIndex].
47        #[unsafe(method(setItemIndex:))]
48        #[unsafe(method_family = none)]
49        pub fn setItemIndex(&self, item_index: NSInteger);
50
51        #[unsafe(method(frame))]
52        #[unsafe(method_family = none)]
53        pub fn frame(&self) -> NSRect;
54
55        /// Setter for [`frame`][Self::frame].
56        #[unsafe(method(setFrame:))]
57        #[unsafe(method_family = none)]
58        pub fn setFrame(&self, frame: NSRect);
59
60        #[cfg(feature = "objc2-core-foundation")]
61        #[unsafe(method(alpha))]
62        #[unsafe(method_family = none)]
63        pub fn alpha(&self) -> CGFloat;
64
65        #[cfg(feature = "objc2-core-foundation")]
66        /// Setter for [`alpha`][Self::alpha].
67        #[unsafe(method(setAlpha:))]
68        #[unsafe(method_family = none)]
69        pub fn setAlpha(&self, alpha: CGFloat);
70
71        #[unsafe(method(layoutAttributesForItemAtIndex:))]
72        #[unsafe(method_family = none)]
73        pub fn layoutAttributesForItemAtIndex(index: NSInteger) -> Retained<Self>;
74    );
75}
76
77/// Methods declared on superclass `NSObject`.
78impl NSScrubberLayoutAttributes {
79    extern_methods!(
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        #[unsafe(method(new))]
85        #[unsafe(method_family = new)]
86        pub fn new() -> Retained<Self>;
87    );
88}
89
90impl DefaultRetained for NSScrubberLayoutAttributes {
91    #[inline]
92    fn default_retained() -> Retained<Self> {
93        Self::new()
94    }
95}
96
97extern_class!(
98    /// `NSScrubberLayout`is an abstract class that describes the layout of items within a
99    /// `NSScrubber`control.
100    ///
101    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscrubberlayout?language=objc)
102    #[unsafe(super(NSObject))]
103    #[thread_kind = MainThreadOnly]
104    #[derive(Debug, PartialEq, Eq, Hash)]
105    pub struct NSScrubberLayout;
106);
107
108extern_conformance!(
109    unsafe impl NSCoding for NSScrubberLayout {}
110);
111
112extern_conformance!(
113    unsafe impl NSObjectProtocol for NSScrubberLayout {}
114);
115
116impl NSScrubberLayout {
117    extern_methods!(
118        /// Specifies a class for describing layout attributes. By default, this is
119        /// `NSScrubberLayoutAttributes,`but subclasses may override this method to use a custom subclass of
120        /// `NSScrubberLayoutAttributes.`
121        #[unsafe(method(layoutAttributesClass))]
122        #[unsafe(method_family = none)]
123        pub fn layoutAttributesClass(mtm: MainThreadMarker) -> &'static AnyClass;
124
125        #[cfg(all(feature = "NSResponder", feature = "NSScrubber", feature = "NSView"))]
126        /// The NSScrubber control that this layout is assigned to, or
127        /// `nil`if the receiver is not assigned to a scrubber.
128        #[unsafe(method(scrubber))]
129        #[unsafe(method_family = none)]
130        pub fn scrubber(&self) -> Option<Retained<NSScrubber>>;
131
132        /// The currently visible rectangle, in the coordinate space of the scrubber content. Returns
133        /// `NSZeroRect`if the receiver is not assigned to a scrubber.
134        #[unsafe(method(visibleRect))]
135        #[unsafe(method_family = none)]
136        pub fn visibleRect(&self) -> NSRect;
137
138        #[unsafe(method(init))]
139        #[unsafe(method_family = init)]
140        pub fn init(this: Allocated<Self>) -> Retained<Self>;
141
142        /// # Safety
143        ///
144        /// `coder` possibly has further requirements.
145        #[unsafe(method(initWithCoder:))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
148
149        /// Signals that layout has been invalidated and the NSScrubber should run a fresh layout pass. Subclasses may define more granular invalidation methods suitable for their own data structures, but those methods should always call up to -invalidateLayout.
150        #[unsafe(method(invalidateLayout))]
151        #[unsafe(method_family = none)]
152        pub fn invalidateLayout(&self);
153
154        /// Following any invalidation in layout,
155        /// `NSScrubber`will call
156        /// `prepareLayout`on its layout object prior to requesting any other layout information. Subclasses should use this method to perform upfront calculations and caching. The base implementation of this method does nothing.
157        #[unsafe(method(prepareLayout))]
158        #[unsafe(method_family = none)]
159        pub fn prepareLayout(&self);
160
161        /// Returns the content size for all elements within the scrubber. The base implementation returns
162        /// `NSZeroSize.`
163        #[unsafe(method(scrubberContentSize))]
164        #[unsafe(method_family = none)]
165        pub fn scrubberContentSize(&self) -> NSSize;
166
167        /// Returns the layout attributes for a single item within the scrubber. The base implementation returns
168        /// `nil.`
169        #[unsafe(method(layoutAttributesForItemAtIndex:))]
170        #[unsafe(method_family = none)]
171        pub fn layoutAttributesForItemAtIndex(
172            &self,
173            index: NSInteger,
174        ) -> Option<Retained<NSScrubberLayoutAttributes>>;
175
176        /// Returns the set of layout attributes for all items within the provided rectangle. The base implementation returns an empty set.
177        #[unsafe(method(layoutAttributesForItemsInRect:))]
178        #[unsafe(method_family = none)]
179        pub fn layoutAttributesForItemsInRect(
180            &self,
181            rect: NSRect,
182        ) -> Retained<NSSet<NSScrubberLayoutAttributes>>;
183
184        /// If
185        /// `YES,`the scrubber will invalidate its layout when the selection changes. The default value is
186        /// `NO.`Subclasses should return
187        /// `YES`if the selection index affects the item layout.
188        #[unsafe(method(shouldInvalidateLayoutForSelectionChange))]
189        #[unsafe(method_family = none)]
190        pub fn shouldInvalidateLayoutForSelectionChange(&self) -> bool;
191
192        /// If
193        /// `YES,`the scrubber will invalidate its layout when an item is highlighted. The default value is
194        /// `NO.`Subclasses should return
195        /// `YES`if the highlight state affects the item layout.
196        #[unsafe(method(shouldInvalidateLayoutForHighlightChange))]
197        #[unsafe(method_family = none)]
198        pub fn shouldInvalidateLayoutForHighlightChange(&self) -> bool;
199
200        /// If
201        /// `YES,`the scrubber will invalidate its layout in response to a change in the visible region. The default value is
202        /// `NO.`Subclasses which rely on the size or origin of the visible region should return
203        /// `YES.`
204        #[unsafe(method(shouldInvalidateLayoutForChangeFromVisibleRect:toVisibleRect:))]
205        #[unsafe(method_family = none)]
206        pub fn shouldInvalidateLayoutForChangeFromVisibleRect_toVisibleRect(
207            &self,
208            from_visible_rect: NSRect,
209            to_visible_rect: NSRect,
210        ) -> bool;
211
212        /// If
213        /// `YES,`the layout object will automatically have its inputs and outputs mirrored in right-to-left interfaces. The default value is
214        /// `YES.`Subclasses that wish to handle RTL layout manually should return
215        /// `NO.`
216        #[unsafe(method(automaticallyMirrorsInRightToLeftLayout))]
217        #[unsafe(method_family = none)]
218        pub fn automaticallyMirrorsInRightToLeftLayout(&self) -> bool;
219    );
220}
221
222/// Methods declared on superclass `NSObject`.
223impl NSScrubberLayout {
224    extern_methods!(
225        #[unsafe(method(new))]
226        #[unsafe(method_family = new)]
227        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
228    );
229}
230
231extern_protocol!(
232    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscrubberflowlayoutdelegate?language=objc)
233    #[cfg(feature = "NSScrubber")]
234    pub unsafe trait NSScrubberFlowLayoutDelegate: NSScrubberDelegate {
235        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
236        #[optional]
237        #[unsafe(method(scrubber:layout:sizeForItemAtIndex:))]
238        #[unsafe(method_family = none)]
239        fn scrubber_layout_sizeForItemAtIndex(
240            &self,
241            scrubber: &NSScrubber,
242            layout: &NSScrubberFlowLayout,
243            item_index: NSInteger,
244        ) -> NSSize;
245    }
246);
247
248extern_class!(
249    /// `NSScrubberFlowLayout`is a concrete layout object that arranges items end-to-end in a linear strip. It supports a fixed inter-item spacing and both fixed- and variable-sized items.
250    ///
251    /// If the associated scrubber's
252    /// `delegate`conforms to
253    /// `NSScrubberFlowLayoutDelegate,`and it implements the
254    /// `scrubber:layout:sizeForItemAtIndex:`method,
255    /// `NSScrubberFlowLayout`will obtain the item size from the delegate. If the delegate does not implement that method, or if the method returns
256    /// `NSZeroSize,`it will fall back to using the layout's
257    /// `itemSize`property. By default, NSScrubberFlowLayout does not invalidate its layout on selection change, highlight change, or visible rectangle change.
258    ///
259    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscrubberflowlayout?language=objc)
260    #[unsafe(super(NSScrubberLayout, NSObject))]
261    #[derive(Debug, PartialEq, Eq, Hash)]
262    pub struct NSScrubberFlowLayout;
263);
264
265extern_conformance!(
266    unsafe impl NSCoding for NSScrubberFlowLayout {}
267);
268
269extern_conformance!(
270    unsafe impl NSObjectProtocol for NSScrubberFlowLayout {}
271);
272
273impl NSScrubberFlowLayout {
274    extern_methods!(
275        #[cfg(feature = "objc2-core-foundation")]
276        /// The amount of horizontal spacing between items in points. The default value is 0.0.
277        #[unsafe(method(itemSpacing))]
278        #[unsafe(method_family = none)]
279        pub fn itemSpacing(&self) -> CGFloat;
280
281        #[cfg(feature = "objc2-core-foundation")]
282        /// Setter for [`itemSpacing`][Self::itemSpacing].
283        #[unsafe(method(setItemSpacing:))]
284        #[unsafe(method_family = none)]
285        pub fn setItemSpacing(&self, item_spacing: CGFloat);
286
287        /// The frame size for each item, if not provided by the scrubber's delegate. The default value is { 50.0, 30.0 }.
288        #[unsafe(method(itemSize))]
289        #[unsafe(method_family = none)]
290        pub fn itemSize(&self) -> NSSize;
291
292        /// Setter for [`itemSize`][Self::itemSize].
293        #[unsafe(method(setItemSize:))]
294        #[unsafe(method_family = none)]
295        pub fn setItemSize(&self, item_size: NSSize);
296
297        #[unsafe(method(invalidateLayoutForItemsAtIndexes:))]
298        #[unsafe(method_family = none)]
299        pub fn invalidateLayoutForItemsAtIndexes(&self, invalid_item_indexes: &NSIndexSet);
300    );
301}
302
303/// Methods declared on superclass `NSScrubberLayout`.
304impl NSScrubberFlowLayout {
305    extern_methods!(
306        #[unsafe(method(init))]
307        #[unsafe(method_family = init)]
308        pub fn init(this: Allocated<Self>) -> Retained<Self>;
309
310        /// # Safety
311        ///
312        /// `coder` possibly has further requirements.
313        #[unsafe(method(initWithCoder:))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
316    );
317}
318
319/// Methods declared on superclass `NSObject`.
320impl NSScrubberFlowLayout {
321    extern_methods!(
322        #[unsafe(method(new))]
323        #[unsafe(method_family = new)]
324        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
325    );
326}
327
328extern_class!(
329    /// `NSScrubberProportionalLayout`is a concrete layout object that sizes each item to some fraction of the scrubber's visible size.
330    ///
331    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsscrubberproportionallayout?language=objc)
332    #[unsafe(super(NSScrubberLayout, NSObject))]
333    #[derive(Debug, PartialEq, Eq, Hash)]
334    pub struct NSScrubberProportionalLayout;
335);
336
337extern_conformance!(
338    unsafe impl NSCoding for NSScrubberProportionalLayout {}
339);
340
341extern_conformance!(
342    unsafe impl NSObjectProtocol for NSScrubberProportionalLayout {}
343);
344
345impl NSScrubberProportionalLayout {
346    extern_methods!(
347        /// The number of items that should fit within the scrubber's viewport at once.
348        #[unsafe(method(numberOfVisibleItems))]
349        #[unsafe(method_family = none)]
350        pub fn numberOfVisibleItems(&self) -> NSInteger;
351
352        /// Setter for [`numberOfVisibleItems`][Self::numberOfVisibleItems].
353        #[unsafe(method(setNumberOfVisibleItems:))]
354        #[unsafe(method_family = none)]
355        pub fn setNumberOfVisibleItems(&self, number_of_visible_items: NSInteger);
356
357        #[unsafe(method(initWithNumberOfVisibleItems:))]
358        #[unsafe(method_family = init)]
359        pub fn initWithNumberOfVisibleItems(
360            this: Allocated<Self>,
361            number_of_visible_items: NSInteger,
362        ) -> Retained<Self>;
363
364        /// # Safety
365        ///
366        /// `coder` possibly has further requirements.
367        #[unsafe(method(initWithCoder:))]
368        #[unsafe(method_family = init)]
369        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
370    );
371}
372
373/// Methods declared on superclass `NSScrubberLayout`.
374impl NSScrubberProportionalLayout {
375    extern_methods!(
376        #[unsafe(method(init))]
377        #[unsafe(method_family = init)]
378        pub fn init(this: Allocated<Self>) -> Retained<Self>;
379    );
380}
381
382/// Methods declared on superclass `NSObject`.
383impl NSScrubberProportionalLayout {
384    extern_methods!(
385        #[unsafe(method(new))]
386        #[unsafe(method_family = new)]
387        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
388    );
389}