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