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")]
84extern_conformance!(
85 unsafe impl NSAnimatablePropertyContainer for NSSplitViewItem {}
86);
87
88extern_conformance!(
89 unsafe impl NSCoding for NSSplitViewItem {}
90);
91
92extern_conformance!(
93 unsafe impl NSObjectProtocol for NSSplitViewItem {}
94);
95
96impl NSSplitViewItem {
97 extern_methods!(
98 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
99 /// Creates an autoreleased SplitViewItem that represents the provided ViewController. All other properties are left at their default.
100 ///
101 /// Parameter `viewController`: The view controller used to set the viewController property
102 ///
103 /// Returns: An autoreleased SplitViewItem.
104 #[unsafe(method(splitViewItemWithViewController:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn splitViewItemWithViewController(
107 view_controller: &NSViewController,
108 ) -> Retained<Self>;
109
110 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
111 /// Creates a split view item representing a sidebar for the provided ViewController.
112 /// Sidebars have standard system behavior, specifically:
113 /// - Translucent material background
114 /// - The ability to collapse/uncollapse on split view size changes
115 /// - The ability to overlay at small split view sizes when in fullscreen
116 /// - canCollapse is set to YES
117 /// - minimumThickness and maximumThickness are set to the standard minimum and maximum sidebar size
118 /// - preferredThicknessFraction is set to the standard fraction for sidebars (0.15)
119 /// - springLoaded is set to YES
120 ///
121 /// Parameter `viewController`: The view controller used to set the viewController property
122 ///
123 /// Returns: An autoreleased SplitViewItem that acts as a sidebar.
124 #[unsafe(method(sidebarWithViewController:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn sidebarWithViewController(
127 view_controller: &NSViewController,
128 ) -> Retained<Self>;
129
130 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
131 /// Creates a split view item representing a content list for the provided ViewController, akin to Mail's message list, Note's note list.
132 /// Content lists have system standard defaults, specifically:
133 /// - minimumThickness and maximumThickness are set to the system standard for content lists
134 /// - automaticMaximumThickness is set to the system standard for content lists
135 /// - preferredThicknessFraction is set to the standard fraction for content lists (0.28 when a neighbor sidebar is visible, 0.33 if not)
136 ///
137 /// Parameter `viewController`: The view controller used to set the viewController property
138 ///
139 /// Returns: An autoreleased SplitViewItem that acts as a content list.
140 #[unsafe(method(contentListWithViewController:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn contentListWithViewController(
143 view_controller: &NSViewController,
144 ) -> Retained<Self>;
145
146 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
147 /// Creates a split view item representing an inspector for the provided ViewController.
148 /// On macOS 14.0 and above inspectors have the following standard system behavior:
149 /// - canCollapse is set to YES
150 /// - minimumThickness and maximumThickness are set to the standard inspector size (270) and are not resizable by default
151 ///
152 /// Parameter `viewController`: The view controller used to set the viewController property
153 ///
154 /// Returns: An autoreleased SplitViewItem that acts as an inspector.
155 #[unsafe(method(inspectorWithViewController:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn inspectorWithViewController(
158 view_controller: &NSViewController,
159 ) -> Retained<Self>;
160
161 /// The standard behavior type of the receiver. See initializers for descriptions of each behavior.
162 #[unsafe(method(behavior))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn behavior(&self) -> NSSplitViewItemBehavior;
165
166 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
167 /// 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.
168 #[unsafe(method(viewController))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn viewController(&self, mtm: MainThreadMarker) -> Retained<NSViewController>;
171
172 #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
173 /// Setter for [`viewController`][Self::viewController].
174 #[unsafe(method(setViewController:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn setViewController(&self, view_controller: &NSViewController);
177
178 /// Whether or not the child ViewController corresponding to the SplitViewItem is collapsed in the SplitViewController. The default is
179 /// `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.
180 #[unsafe(method(isCollapsed))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn isCollapsed(&self) -> bool;
183
184 /// Setter for [`isCollapsed`][Self::isCollapsed].
185 #[unsafe(method(setCollapsed:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn setCollapsed(&self, collapsed: bool);
188
189 /// Whether or not the child view controller is collapsible from user interaction - whether by dragging or double clicking a divider. The default is
190 /// `NO.`
191 #[unsafe(method(canCollapse))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn canCollapse(&self) -> bool;
194
195 /// Setter for [`canCollapse`][Self::canCollapse].
196 #[unsafe(method(setCanCollapse:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn setCanCollapse(&self, can_collapse: bool);
199
200 /// The resize behavior when the receiver toggles its `collapsed` state programmatically, both animatedly and not. Defaults to `.Default`.
201 #[unsafe(method(collapseBehavior))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn collapseBehavior(&self) -> NSSplitViewItemCollapseBehavior;
204
205 /// Setter for [`collapseBehavior`][Self::collapseBehavior].
206 #[unsafe(method(setCollapseBehavior:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn setCollapseBehavior(
209 &self,
210 collapse_behavior: NSSplitViewItemCollapseBehavior,
211 );
212
213 #[cfg(feature = "objc2-core-foundation")]
214 /// 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.
215 #[unsafe(method(minimumThickness))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn minimumThickness(&self) -> CGFloat;
218
219 #[cfg(feature = "objc2-core-foundation")]
220 /// Setter for [`minimumThickness`][Self::minimumThickness].
221 #[unsafe(method(setMinimumThickness:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setMinimumThickness(&self, minimum_thickness: CGFloat);
224
225 #[cfg(feature = "objc2-core-foundation")]
226 /// 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.
227 #[unsafe(method(maximumThickness))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn maximumThickness(&self) -> CGFloat;
230
231 #[cfg(feature = "objc2-core-foundation")]
232 /// Setter for [`maximumThickness`][Self::maximumThickness].
233 #[unsafe(method(setMaximumThickness:))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn setMaximumThickness(&self, maximum_thickness: CGFloat);
236
237 #[cfg(feature = "objc2-core-foundation")]
238 /// 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.
239 #[unsafe(method(preferredThicknessFraction))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn preferredThicknessFraction(&self) -> CGFloat;
242
243 #[cfg(feature = "objc2-core-foundation")]
244 /// Setter for [`preferredThicknessFraction`][Self::preferredThicknessFraction].
245 #[unsafe(method(setPreferredThicknessFraction:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setPreferredThicknessFraction(&self, preferred_thickness_fraction: CGFloat);
248
249 #[cfg(feature = "NSLayoutConstraint")]
250 /// 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
251 /// `NSLayoutPriorityDefaultLow.`
252 #[unsafe(method(holdingPriority))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn holdingPriority(&self) -> NSLayoutPriority;
255
256 #[cfg(feature = "NSLayoutConstraint")]
257 /// Setter for [`holdingPriority`][Self::holdingPriority].
258 #[unsafe(method(setHoldingPriority:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn setHoldingPriority(&self, holding_priority: NSLayoutPriority);
261
262 #[cfg(feature = "objc2-core-foundation")]
263 /// 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.
264 #[unsafe(method(automaticMaximumThickness))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn automaticMaximumThickness(&self) -> CGFloat;
267
268 #[cfg(feature = "objc2-core-foundation")]
269 /// Setter for [`automaticMaximumThickness`][Self::automaticMaximumThickness].
270 #[unsafe(method(setAutomaticMaximumThickness:))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn setAutomaticMaximumThickness(&self, automatic_maximum_thickness: CGFloat);
273
274 /// 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.
275 #[unsafe(method(isSpringLoaded))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn isSpringLoaded(&self) -> bool;
278
279 /// Setter for [`isSpringLoaded`][Self::isSpringLoaded].
280 #[unsafe(method(setSpringLoaded:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn setSpringLoaded(&self, spring_loaded: bool);
283
284 /// 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.
285 /// Defaults to YES for Sidebars and NO for Inspectors.
286 /// - Note: Setting `canCollapse` for sidebars will reset this value to that new value.
287 #[unsafe(method(canCollapseFromWindowResize))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn canCollapseFromWindowResize(&self) -> bool;
290
291 /// Setter for [`canCollapseFromWindowResize`][Self::canCollapseFromWindowResize].
292 #[unsafe(method(setCanCollapseFromWindowResize:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn setCanCollapseFromWindowResize(&self, can_collapse_from_window_resize: bool);
295
296 /// 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.
297 #[unsafe(method(allowsFullHeightLayout))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn allowsFullHeightLayout(&self) -> bool;
300
301 /// Setter for [`allowsFullHeightLayout`][Self::allowsFullHeightLayout].
302 #[unsafe(method(setAllowsFullHeightLayout:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn setAllowsFullHeightLayout(&self, allows_full_height_layout: bool);
305
306 #[cfg(feature = "NSWindow")]
307 /// Specifies a preference for the style of separator displayed between the titlebar and the content of the split view item.
308 ///
309 /// For this value to be applicable, the item's view must be associated with its own titlebar section (see `NSTrackingSeparatorToolbarItem` for more info).
310 /// The default value is NSTitlebarSeparatorStyleAutomatic. This value is subject to the containing window's preference and can be overridden.
311 #[unsafe(method(titlebarSeparatorStyle))]
312 #[unsafe(method_family = none)]
313 pub unsafe fn titlebarSeparatorStyle(&self) -> NSTitlebarSeparatorStyle;
314
315 #[cfg(feature = "NSWindow")]
316 /// Setter for [`titlebarSeparatorStyle`][Self::titlebarSeparatorStyle].
317 #[unsafe(method(setTitlebarSeparatorStyle:))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn setTitlebarSeparatorStyle(
320 &self,
321 titlebar_separator_style: NSTitlebarSeparatorStyle,
322 );
323 );
324}
325
326/// Methods declared on superclass `NSObject`.
327impl NSSplitViewItem {
328 extern_methods!(
329 #[unsafe(method(init))]
330 #[unsafe(method_family = init)]
331 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
332
333 #[unsafe(method(new))]
334 #[unsafe(method_family = new)]
335 pub unsafe fn new() -> Retained<Self>;
336 );
337}