objc2_app_kit/generated/
NSSplitViewItem.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
12/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewitembehavior?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSSplitViewItemBehavior(pub NSInteger);
17impl NSSplitViewItemBehavior {
18    #[doc(alias = "NSSplitViewItemBehaviorDefault")]
19    pub const Default: Self = Self(0);
20    #[doc(alias = "NSSplitViewItemBehaviorSidebar")]
21    pub const Sidebar: Self = Self(1);
22    #[doc(alias = "NSSplitViewItemBehaviorContentList")]
23    pub const ContentList: Self = Self(2);
24    #[doc(alias = "NSSplitViewItemBehaviorInspector")]
25    pub const Inspector: Self = Self(3);
26}
27
28unsafe impl Encode for NSSplitViewItemBehavior {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSSplitViewItemBehavior {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewitemcollapsebehavior?language=objc)
37// NS_ENUM
38#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct NSSplitViewItemCollapseBehavior(pub NSInteger);
41impl NSSplitViewItemCollapseBehavior {
42    /// The item uses the default collapsing behavior for its set `behavior`. The default may change over time.
43    #[doc(alias = "NSSplitViewItemCollapseBehaviorDefault")]
44    pub const Default: Self = Self(0);
45    /// The item prefers to keep the other panes at their current size and position on screen, potentially growing or shrinking the window in the direction to best preserve that. But it will break that preference in order to keep the window fully on screen or when in full screen.
46    #[doc(alias = "NSSplitViewItemCollapseBehaviorPreferResizingSplitViewWithFixedSiblings")]
47    pub const PreferResizingSplitViewWithFixedSiblings: Self = Self(1);
48    /// The item prefers to resize the other split panes. This will be broken when uncollapsing if the item can't fully uncollapse before hitting the minimum size of the other panes or the window.
49    #[doc(alias = "NSSplitViewItemCollapseBehaviorPreferResizingSiblingsWithFixedSplitView")]
50    pub const PreferResizingSiblingsWithFixedSplitView: Self = Self(2);
51    /// The item will collapse/uncollapse purely from a constraint animation, with a constraint priority of the item’s `holdingPriority`. This could result in a partial internal content resize and window resize, and has no implications for keeping the window on screen. External constraints can be used to tweak exactly how the animation affects item, sibling, and window size and positions.
52    #[doc(alias = "NSSplitViewItemCollapseBehaviorUseConstraints")]
53    pub const UseConstraints: Self = Self(3);
54}
55
56unsafe impl Encode for NSSplitViewItemCollapseBehavior {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for NSSplitViewItemCollapseBehavior {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern "C" {
65    /// This constant can be used with any sizing related
66    /// `NSSplitViewItem`properties to unset their values.
67    ///
68    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewitemunspecifieddimension?language=objc)
69    #[cfg(feature = "objc2-core-foundation")]
70    pub static NSSplitViewItemUnspecifiedDimension: CGFloat;
71}
72
73extern_class!(
74    /// NSSplitViewItem implements the items used in an NSSplitViewController.
75    /// The item describes a child ViewController's state in a SplitViewController, e.g. its collapsibility, holding priority and other metrics, and collapsed state.
76    ///
77    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewitem?language=objc)
78    #[unsafe(super(NSObject))]
79    #[derive(Debug, PartialEq, Eq, Hash)]
80    pub struct NSSplitViewItem;
81);
82
83#[cfg(feature = "NSAnimation")]
84unsafe impl NSAnimatablePropertyContainer for NSSplitViewItem {}
85
86unsafe impl NSCoding for NSSplitViewItem {}
87
88unsafe impl NSObjectProtocol for NSSplitViewItem {}
89
90impl NSSplitViewItem {
91    extern_methods!(
92        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
93        /// Creates an autoreleased SplitViewItem that represents the provided ViewController. All other properties are left at their default.
94        ///
95        /// Parameter `viewController`: The view controller used to set the viewController property
96        ///
97        /// Returns: An autoreleased SplitViewItem.
98        #[unsafe(method(splitViewItemWithViewController:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn splitViewItemWithViewController(
101            view_controller: &NSViewController,
102        ) -> Retained<Self>;
103
104        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
105        /// Creates a split view item representing a sidebar for the provided ViewController.
106        /// Sidebars have standard system behavior, specifically:
107        /// - Translucent material background
108        /// - The ability to collapse/uncollapse on split view size changes
109        /// - The ability to overlay at small split view sizes when in fullscreen
110        /// - canCollapse is set to YES
111        /// - minimumThickness and maximumThickness are set to the standard minimum and maximum sidebar size
112        /// - preferredThicknessFraction is set to the standard fraction for sidebars (0.15)
113        /// - springLoaded is set to YES
114        ///
115        /// Parameter `viewController`: The view controller used to set the viewController property
116        ///
117        /// Returns: An autoreleased SplitViewItem that acts as a sidebar.
118        #[unsafe(method(sidebarWithViewController:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn sidebarWithViewController(
121            view_controller: &NSViewController,
122        ) -> Retained<Self>;
123
124        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
125        /// Creates a split view item representing a content list for the provided ViewController, akin to Mail's message list, Note's note list.
126        /// Content lists have system standard defaults, specifically:
127        /// - minimumThickness and maximumThickness are set to the system standard for content lists
128        /// - automaticMaximumThickness is set to the system standard for content lists
129        /// - preferredThicknessFraction is set to the standard fraction for content lists (0.28 when a neighbor sidebar is visible, 0.33 if not)
130        ///
131        /// Parameter `viewController`: The view controller used to set the viewController property
132        ///
133        /// Returns: An autoreleased SplitViewItem that acts as a content list.
134        #[unsafe(method(contentListWithViewController:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn contentListWithViewController(
137            view_controller: &NSViewController,
138        ) -> Retained<Self>;
139
140        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
141        /// Creates a split view item representing an inspector for the provided ViewController.
142        /// On macOS 14.0 and above inspectors have the following standard system behavior:
143        /// - canCollapse is set to YES
144        /// - minimumThickness and maximumThickness are set to the standard inspector size (270) and are not resizable by default
145        ///
146        /// Parameter `viewController`: The view controller used to set the viewController property
147        ///
148        /// Returns: An autoreleased SplitViewItem that acts as an inspector.
149        #[unsafe(method(inspectorWithViewController:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn inspectorWithViewController(
152            view_controller: &NSViewController,
153        ) -> Retained<Self>;
154
155        /// The standard behavior type of the receiver. See initializers for descriptions of each behavior.
156        #[unsafe(method(behavior))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn behavior(&self) -> NSSplitViewItemBehavior;
159
160        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
161        /// The view controller represented by the SplitViewItem. An exception will be thrown if a new viewController is set while the receiving SplitViewItem is added to a SplitViewController.
162        #[unsafe(method(viewController))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn viewController(&self, mtm: MainThreadMarker) -> Retained<NSViewController>;
165
166        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
167        /// Setter for [`viewController`][Self::viewController].
168        #[unsafe(method(setViewController:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setViewController(&self, view_controller: &NSViewController);
171
172        /// Whether or not the child ViewController corresponding to the SplitViewItem is collapsed in the SplitViewController. The default is
173        /// `NO.`This can be set with the animator proxy to animate the collapse or uncollapse. The exact animation used can be customized by setting it in the -animations dictionary with a key of "collapsed". If this is set to YES before it is added to the SplitViewController, it will be initially collapsed and the SplitViewController will not cause the view to be loaded until it is uncollapsed. This is KVC/KVO compliant and will be updated if the value changes from user interaction.
174        #[unsafe(method(isCollapsed))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn isCollapsed(&self) -> bool;
177
178        /// Setter for [`isCollapsed`][Self::isCollapsed].
179        #[unsafe(method(setCollapsed:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setCollapsed(&self, collapsed: bool);
182
183        /// Whether or not the child view controller is collapsible from user interaction - whether by dragging or double clicking a divider. The default is
184        /// `NO.`
185        #[unsafe(method(canCollapse))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn canCollapse(&self) -> bool;
188
189        /// Setter for [`canCollapse`][Self::canCollapse].
190        #[unsafe(method(setCanCollapse:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn setCanCollapse(&self, can_collapse: bool);
193
194        /// The resize behavior when the receiver toggles its `collapsed` state programmatically, both animatedly and not. Defaults to `.Default`.
195        #[unsafe(method(collapseBehavior))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn collapseBehavior(&self) -> NSSplitViewItemCollapseBehavior;
198
199        /// Setter for [`collapseBehavior`][Self::collapseBehavior].
200        #[unsafe(method(setCollapseBehavior:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setCollapseBehavior(
203            &self,
204            collapse_behavior: NSSplitViewItemCollapseBehavior,
205        );
206
207        #[cfg(feature = "objc2-core-foundation")]
208        /// A convenience to set the minimum thickness of the split view item -- width for "vertical" split views, height otherwise. If NSSplitViewItemUnspecifiedDimension, no minimum size is enforced by the SplitViewItem, although constraints in the contained view hierarchy might have constraints specify some minimum size on their own. Defaults to NSSplitViewItemUnspecifiedDimension.
209        #[unsafe(method(minimumThickness))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn minimumThickness(&self) -> CGFloat;
212
213        #[cfg(feature = "objc2-core-foundation")]
214        /// Setter for [`minimumThickness`][Self::minimumThickness].
215        #[unsafe(method(setMinimumThickness:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setMinimumThickness(&self, minimum_thickness: CGFloat);
218
219        #[cfg(feature = "objc2-core-foundation")]
220        /// A convenience to set the maximum thickness of the split view item -- width for "vertical" split views, height otherwise. If NSSplitViewItemUnspecifiedDimension, no maximum size is enforced by the SplitViewItem, although constraints in the contained view hierarchy might have constraints specify some maximum size on their own. Defaults to NSSplitViewItemUnspecifiedDimension.
221        #[unsafe(method(maximumThickness))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn maximumThickness(&self) -> CGFloat;
224
225        #[cfg(feature = "objc2-core-foundation")]
226        /// Setter for [`maximumThickness`][Self::maximumThickness].
227        #[unsafe(method(setMaximumThickness:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setMaximumThickness(&self, maximum_thickness: CGFloat);
230
231        #[cfg(feature = "objc2-core-foundation")]
232        /// The percentage of the contained NSSplitView that the NSSplitViewItem prefers to encompass. This is used when double-clicking on a neighbor divider to return to that standard ratio. As well as after entering fullscreen to determine the initial size of the receiver. Defaults to NSSplitViewItemUnspecifiedDimension, which means no resize will occur on double-clicks, and the absolute size is preserved when entering fullscreen.
233        #[unsafe(method(preferredThicknessFraction))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn preferredThicknessFraction(&self) -> CGFloat;
236
237        #[cfg(feature = "objc2-core-foundation")]
238        /// Setter for [`preferredThicknessFraction`][Self::preferredThicknessFraction].
239        #[unsafe(method(setPreferredThicknessFraction:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn setPreferredThicknessFraction(&self, preferred_thickness_fraction: CGFloat);
242
243        #[cfg(feature = "NSLayoutConstraint")]
244        /// Sets the priority under which a SplitViewItem will hold its width (for a vertical split view) or height (for a horizontal split view). The view with the lowest priority will be the first to take on additional width if the split view grows or shrinks. The default is
245        /// `NSLayoutPriorityDefaultLow.`
246        #[unsafe(method(holdingPriority))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn holdingPriority(&self) -> NSLayoutPriority;
249
250        #[cfg(feature = "NSLayoutConstraint")]
251        /// Setter for [`holdingPriority`][Self::holdingPriority].
252        #[unsafe(method(setHoldingPriority:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setHoldingPriority(&self, holding_priority: NSLayoutPriority);
255
256        #[cfg(feature = "objc2-core-foundation")]
257        /// The maximum thickness of the split view item when resizing due to automatic sizing, such as entering fullscreen with a set preferredThicknessFraction or proportional sizing. The user can still resize up to the absolute maximum size by dragging the divider or otherwise. If NSSplitViewItemUnspecifiedDimension, no automatic maximum is enforced. Defaults to NSSplitViewItemUnspecifiedDimension.
258        #[unsafe(method(automaticMaximumThickness))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn automaticMaximumThickness(&self) -> CGFloat;
261
262        #[cfg(feature = "objc2-core-foundation")]
263        /// Setter for [`automaticMaximumThickness`][Self::automaticMaximumThickness].
264        #[unsafe(method(setAutomaticMaximumThickness:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn setAutomaticMaximumThickness(&self, automatic_maximum_thickness: CGFloat);
267
268        /// If YES, the split view item can be temporarily uncollapsed during a drag by hovering or deep clicking on its neighboring divider. Defaults to NO.
269        #[unsafe(method(isSpringLoaded))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn isSpringLoaded(&self) -> bool;
272
273        /// Setter for [`isSpringLoaded`][Self::isSpringLoaded].
274        #[unsafe(method(setSpringLoaded:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
277
278        /// If YES, the item can be collapsed from a window resize. This can differ from `canCollapse`, to allow divider collapsing but not window resize collapsing or vice versa.
279        /// Defaults to YES for Sidebars and NO for Inspectors.
280        /// - Note: Setting `canCollapse` for sidebars will reset this value to that new value.
281        #[unsafe(method(canCollapseFromWindowResize))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn canCollapseFromWindowResize(&self) -> bool;
284
285        /// Setter for [`canCollapseFromWindowResize`][Self::canCollapseFromWindowResize].
286        #[unsafe(method(setCanCollapseFromWindowResize:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn setCanCollapseFromWindowResize(&self, can_collapse_from_window_resize: bool);
289
290        /// Whether or not a sidebar or inspector is allowed to be full height in the window when the `NSFullSizeContentViewWindowMask` style mask is also set. Only applies to NSSplitViewItemBehaviorSidebar and NSSplitViewItemBehaviorInspector. Defaults to YES.
291        #[unsafe(method(allowsFullHeightLayout))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn allowsFullHeightLayout(&self) -> bool;
294
295        /// Setter for [`allowsFullHeightLayout`][Self::allowsFullHeightLayout].
296        #[unsafe(method(setAllowsFullHeightLayout:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setAllowsFullHeightLayout(&self, allows_full_height_layout: bool);
299
300        #[cfg(feature = "NSWindow")]
301        /// Specifies a preference for the style of separator displayed between the titlebar and the content of the split view item.
302        ///
303        /// For this value to be applicable, the item's view must be associated with its own titlebar section (see `NSTrackingSeparatorToolbarItem` for more info).
304        /// The default value is NSTitlebarSeparatorStyleAutomatic. This value is subject to the containing window's preference and can be overridden.
305        #[unsafe(method(titlebarSeparatorStyle))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn titlebarSeparatorStyle(&self) -> NSTitlebarSeparatorStyle;
308
309        #[cfg(feature = "NSWindow")]
310        /// Setter for [`titlebarSeparatorStyle`][Self::titlebarSeparatorStyle].
311        #[unsafe(method(setTitlebarSeparatorStyle:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn setTitlebarSeparatorStyle(
314            &self,
315            titlebar_separator_style: NSTitlebarSeparatorStyle,
316        );
317    );
318}
319
320/// Methods declared on superclass `NSObject`.
321impl NSSplitViewItem {
322    extern_methods!(
323        #[unsafe(method(init))]
324        #[unsafe(method_family = init)]
325        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
326
327        #[unsafe(method(new))]
328        #[unsafe(method_family = new)]
329        pub unsafe fn new() -> Retained<Self>;
330    );
331}