objc2_app_kit/generated/
NSSplitViewController.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 "C" {
13    /// This constant can be used with any sizing related
14    /// `NSSplitViewController`properties to get the default system behavior.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewcontrollerautomaticdimension?language=objc)
17    #[cfg(feature = "objc2-core-foundation")]
18    pub static NSSplitViewControllerAutomaticDimension: CGFloat;
19}
20
21extern_class!(
22    /// NSSplitViewController is a container view controller that manages side-by-side (horizontal or vertical) children view controllers.
23    /// Views are lazily loaded. For instance, adding a collapsed SplitViewItem will not load the associated ViewController's view until it is uncollapsed.
24    /// The NSSplitViewController is set as the delegate of its managed NSSplitView. Any overrides of NSSplitViewDelegate methods must call super.
25    /// Only the
26    /// `-vertical,``-autosaveName,`and divider properties should be manipulated on the managed NSSplitView. Changing other properties (such as delegate, manipulating subviews, holding priorities) will cause an exception to be thrown.
27    /// Autolayout must be used with NSSplitViewController to properly control the layout of the child views and the animations of collapses and reveals. e.g., Constraints can be used to setup whether a window should grow/shrink or stay the same size when showing and hiding a sidebar.
28    /// NSViewController's methods
29    /// `-addChildViewController:,``-insertViewController:atIndex:,`and
30    /// `-removeChildViewControllerAtIndex:`can all be used as convience methods to add children; default SplitViewItems will be appropriately created or destroyed.
31    ///
32    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nssplitviewcontroller?language=objc)
33    #[unsafe(super(NSViewController, NSResponder, NSObject))]
34    #[derive(Debug, PartialEq, Eq, Hash)]
35    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
36    pub struct NSSplitViewController;
37);
38
39#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
40extern_conformance!(
41    unsafe impl NSCoding for NSSplitViewController {}
42);
43
44#[cfg(all(
45    feature = "NSKeyValueBinding",
46    feature = "NSResponder",
47    feature = "NSViewController"
48))]
49extern_conformance!(
50    unsafe impl NSEditor for NSSplitViewController {}
51);
52
53#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
54extern_conformance!(
55    unsafe impl NSObjectProtocol for NSSplitViewController {}
56);
57
58#[cfg(all(
59    feature = "NSResponder",
60    feature = "NSStoryboardSegue",
61    feature = "NSViewController"
62))]
63extern_conformance!(
64    unsafe impl NSSeguePerforming for NSSplitViewController {}
65);
66
67#[cfg(all(
68    feature = "NSResponder",
69    feature = "NSSplitView",
70    feature = "NSViewController"
71))]
72extern_conformance!(
73    unsafe impl NSSplitViewDelegate for NSSplitViewController {}
74);
75
76#[cfg(all(
77    feature = "NSResponder",
78    feature = "NSUserInterfaceItemIdentification",
79    feature = "NSViewController"
80))]
81extern_conformance!(
82    unsafe impl NSUserInterfaceItemIdentification for NSSplitViewController {}
83);
84
85#[cfg(all(
86    feature = "NSResponder",
87    feature = "NSUserInterfaceValidation",
88    feature = "NSViewController"
89))]
90extern_conformance!(
91    unsafe impl NSUserInterfaceValidations for NSSplitViewController {}
92);
93
94#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
95impl NSSplitViewController {
96    extern_methods!(
97        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
98        /// The split view managed by the SplitViewController. This can be used to customize view properties such as the dividerStyle, vertical, and autosaveName. It is not guaranteed to be the same view as the receiver’s 'view' property. The default created splitView is vertical with a dividerStyle of
99        /// `NSSplitViewDividerStyleThin.`To provide a custom NSSplitView, set the splitView property anytime before self.viewLoaded is YES.
100        #[unsafe(method(splitView))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn splitView(&self) -> Retained<NSSplitView>;
103
104        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
105        /// Setter for [`splitView`][Self::splitView].
106        #[unsafe(method(setSplitView:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setSplitView(&self, split_view: &NSSplitView);
109
110        #[cfg(feature = "NSSplitViewItem")]
111        /// The array of SplitViewItems that correspond to the current child view controllers. After a child view controller is added to the receiving splitViewController, a NSSplitViewItem with the default values will be created for it. Once the child is removed, its corresponding splitViewItem will be removed from the splitViewItems array. Setting this will call through to
112        /// `-insertSplitViewItem:atIndex`and
113        /// `-removeSplitViewItem:`for items that are new or need removal.
114        #[unsafe(method(splitViewItems))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn splitViewItems(&self) -> Retained<NSArray<NSSplitViewItem>>;
117
118        #[cfg(feature = "NSSplitViewItem")]
119        /// Setter for [`splitViewItems`][Self::splitViewItems].
120        #[unsafe(method(setSplitViewItems:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setSplitViewItems(&self, split_view_items: &NSArray<NSSplitViewItem>);
123
124        #[cfg(feature = "NSSplitViewItem")]
125        /// Adds a SplitViewItem to the end of the SplitViewController. If the receiver's view is loaded and the SplitViewItem is not collapsed, the SplitViewItem's viewController's view will be loaded and added to the splitView. This calls through to -insertSplitViewItem:atIndex:.
126        ///
127        /// Parameter `splitViewItem`: The SplitViewItem to add. It must have a viewController set by the time it is added or an exception will be thrown. An exception will also be thrown if splitViewItem is nil.
128        #[unsafe(method(addSplitViewItem:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn addSplitViewItem(&self, split_view_item: &NSSplitViewItem);
131
132        #[cfg(feature = "NSSplitViewItem")]
133        /// Adds a SplitViewItem to a given index in the SplitViewController. If the receiver's view is loaded and the SplitViewItem is not collapsed, the SplitViewItem's viewController's view will be loaded and added to the
134        /// `splitView.`Subclasses must call through
135        /// `-insertSplitViewItem:atIndex:`to add a SplitViewItem.
136        ///
137        /// Parameter `splitViewItem`: The SplitViewItem to add. It must have a
138        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if splitViewItem is nil.
139        ///
140        /// Parameter `index`: The index to add the SplitViewItem at. Will throw an exception if
141        /// `index`<
142        /// 0 or
143        /// `index`>
144        /// `splitViewItems.count`
145        #[unsafe(method(insertSplitViewItem:atIndex:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn insertSplitViewItem_atIndex(
148            &self,
149            split_view_item: &NSSplitViewItem,
150            index: NSInteger,
151        );
152
153        #[cfg(feature = "NSSplitViewItem")]
154        /// Removes a SplitViewItem from the receiver. The layout of the
155        /// `splitView`will be adjusted for its removal. Subclasses must call through
156        /// `-removeSplitViewItem:`to remove a SplitViewItem.
157        ///
158        /// Parameter `splitViewItem`: The SplitViewItem to remove. An exception will be thrown if
159        /// `splitViewItem`is not in the SplitViewController or if it is nil.
160        #[unsafe(method(removeSplitViewItem:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn removeSplitViewItem(&self, split_view_item: &NSSplitViewItem);
163
164        #[cfg(feature = "NSSplitViewItem")]
165        /// Returns the corresponding SplitViewItem for a given child ViewController.
166        ///
167        /// Parameter `viewController`: The ViewController to look up.
168        ///
169        /// Returns: The corresponding SplitViewItem. Returns nil if
170        /// `viewController`is not a child of the SplitViewController.
171        #[unsafe(method(splitViewItemForViewController:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn splitViewItemForViewController(
174            &self,
175            view_controller: &NSViewController,
176        ) -> Option<Retained<NSSplitViewItem>>;
177
178        #[cfg(feature = "objc2-core-foundation")]
179        /// The minimum thickness in the primary axis of split view (width for "vertical", height otherwise) before sidebar items will automatically collapse. If reshown in fullscreen, they will overlay over the other split items.
180        /// Auto-collapsed sidebars will automatically uncollapse if the thickness is increased back to or past the minimum thickness.
181        /// Defaults to
182        /// `NSSplitViewControllerAutomaticDimension,`which will use the effective minimum sizes of the split view item views as described by constraints in the window to determine the minimum size for inline sidebars. Once constraints establishing the minimum size can't be satisfied for all non-collapsed split panes, all sidebars will auto-collapse. When fullscreen, if a sidebar tries to uncollapse in this state, it will overlay.
183        #[unsafe(method(minimumThicknessForInlineSidebars))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn minimumThicknessForInlineSidebars(&self) -> CGFloat;
186
187        #[cfg(feature = "objc2-core-foundation")]
188        /// Setter for [`minimumThicknessForInlineSidebars`][Self::minimumThicknessForInlineSidebars].
189        #[unsafe(method(setMinimumThicknessForInlineSidebars:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setMinimumThicknessForInlineSidebars(
192            &self,
193            minimum_thickness_for_inline_sidebars: CGFloat,
194        );
195
196        #[cfg(feature = "NSUserInterfaceValidation")]
197        /// Validates items with an action of `toggleSidebar:` to reflect the status of the sidebar item contained within the receiver.
198        #[unsafe(method(validateUserInterfaceItem:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn validateUserInterfaceItem(
201            &self,
202            item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
203        ) -> bool;
204
205        #[unsafe(method(viewDidLoad))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn viewDidLoad(&self);
208
209        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
210        #[unsafe(method(splitView:canCollapseSubview:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn splitView_canCollapseSubview(
213            &self,
214            split_view: &NSSplitView,
215            subview: &NSView,
216        ) -> bool;
217
218        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
219        #[deprecated = "NSSplitView no longer supports collapsing sections via double-click. This delegate method is never called, and NSSplitViewController's implementation always returns NO."]
220        #[unsafe(method(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex(
223            &self,
224            split_view: &NSSplitView,
225            subview: &NSView,
226            divider_index: NSInteger,
227        ) -> bool;
228
229        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
230        #[unsafe(method(splitView:shouldHideDividerAtIndex:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn splitView_shouldHideDividerAtIndex(
233            &self,
234            split_view: &NSSplitView,
235            divider_index: NSInteger,
236        ) -> bool;
237
238        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
239        #[unsafe(method(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn splitView_effectiveRect_forDrawnRect_ofDividerAtIndex(
242            &self,
243            split_view: &NSSplitView,
244            proposed_effective_rect: NSRect,
245            drawn_rect: NSRect,
246            divider_index: NSInteger,
247        ) -> NSRect;
248
249        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
250        #[unsafe(method(splitView:additionalEffectiveRectOfDividerAtIndex:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn splitView_additionalEffectiveRectOfDividerAtIndex(
253            &self,
254            split_view: &NSSplitView,
255            divider_index: NSInteger,
256        ) -> NSRect;
257    );
258}
259
260/// Methods declared on superclass `NSViewController`.
261#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
262impl NSSplitViewController {
263    extern_methods!(
264        #[cfg(feature = "NSNib")]
265        #[unsafe(method(initWithNibName:bundle:))]
266        #[unsafe(method_family = init)]
267        pub unsafe fn initWithNibName_bundle(
268            this: Allocated<Self>,
269            nib_name_or_nil: Option<&NSNibName>,
270            nib_bundle_or_nil: Option<&NSBundle>,
271        ) -> Retained<Self>;
272
273        #[unsafe(method(initWithCoder:))]
274        #[unsafe(method_family = init)]
275        pub unsafe fn initWithCoder(
276            this: Allocated<Self>,
277            coder: &NSCoder,
278        ) -> Option<Retained<Self>>;
279    );
280}
281
282/// Methods declared on superclass `NSResponder`.
283#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
284impl NSSplitViewController {
285    extern_methods!(
286        #[unsafe(method(init))]
287        #[unsafe(method_family = init)]
288        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
289    );
290}
291
292/// Methods declared on superclass `NSObject`.
293#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
294impl NSSplitViewController {
295    extern_methods!(
296        #[unsafe(method(new))]
297        #[unsafe(method_family = new)]
298        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
299    );
300}
301
302/// NSSplitViewControllerToggleSidebarAction.
303#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
304impl NSSplitViewController {
305    extern_methods!(
306        /// Animatedly collapses or uncollapses the first sidebar split view item in the receiver. Does nothing if the receiver does not contain any sidebars.
307        #[unsafe(method(toggleSidebar:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn toggleSidebar(&self, sender: Option<&AnyObject>);
310
311        /// Animatedly collapses or uncollapses the first inspector split view item in the receiver. Does nothing if the receiver does not contain any inspectors.
312        #[unsafe(method(toggleInspector:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn toggleInspector(&self, sender: Option<&AnyObject>);
315    );
316}