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