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"))]
40unsafe impl NSCoding for NSSplitViewController {}
41
42#[cfg(all(
43    feature = "NSKeyValueBinding",
44    feature = "NSResponder",
45    feature = "NSViewController"
46))]
47unsafe impl NSEditor for NSSplitViewController {}
48
49#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
50unsafe impl NSObjectProtocol for NSSplitViewController {}
51
52#[cfg(all(
53    feature = "NSResponder",
54    feature = "NSStoryboardSegue",
55    feature = "NSViewController"
56))]
57unsafe impl NSSeguePerforming for NSSplitViewController {}
58
59#[cfg(all(
60    feature = "NSResponder",
61    feature = "NSSplitView",
62    feature = "NSViewController"
63))]
64unsafe impl NSSplitViewDelegate for NSSplitViewController {}
65
66#[cfg(all(
67    feature = "NSResponder",
68    feature = "NSUserInterfaceItemIdentification",
69    feature = "NSViewController"
70))]
71unsafe impl NSUserInterfaceItemIdentification for NSSplitViewController {}
72
73#[cfg(all(
74    feature = "NSResponder",
75    feature = "NSUserInterfaceValidation",
76    feature = "NSViewController"
77))]
78unsafe impl NSUserInterfaceValidations for NSSplitViewController {}
79
80#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
81impl NSSplitViewController {
82    extern_methods!(
83        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
84        /// 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
85        /// `NSSplitViewDividerStyleThin.`To provide a custom NSSplitView, set the splitView property anytime before self.viewLoaded is YES.
86        #[unsafe(method(splitView))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn splitView(&self) -> Retained<NSSplitView>;
89
90        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
91        /// Setter for [`splitView`][Self::splitView].
92        #[unsafe(method(setSplitView:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn setSplitView(&self, split_view: &NSSplitView);
95
96        #[cfg(feature = "NSSplitViewItem")]
97        /// 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
98        /// `-insertSplitViewItem:atIndex`and
99        /// `-removeSplitViewItem:`for items that are new or need removal.
100        #[unsafe(method(splitViewItems))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn splitViewItems(&self) -> Retained<NSArray<NSSplitViewItem>>;
103
104        #[cfg(feature = "NSSplitViewItem")]
105        /// Setter for [`splitViewItems`][Self::splitViewItems].
106        #[unsafe(method(setSplitViewItems:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setSplitViewItems(&self, split_view_items: &NSArray<NSSplitViewItem>);
109
110        #[cfg(feature = "NSSplitViewItem")]
111        /// 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:.
112        ///
113        /// 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.
114        #[unsafe(method(addSplitViewItem:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn addSplitViewItem(&self, split_view_item: &NSSplitViewItem);
117
118        #[cfg(feature = "NSSplitViewItem")]
119        /// 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
120        /// `splitView.`Subclasses must call through
121        /// `-insertSplitViewItem:atIndex:`to add a SplitViewItem.
122        ///
123        /// Parameter `splitViewItem`: The SplitViewItem to add. It must have a
124        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if splitViewItem is nil.
125        ///
126        /// Parameter `index`: The index to add the SplitViewItem at. Will throw an exception if
127        /// `index`<
128        /// 0 or
129        /// `index`>
130        /// `splitViewItems.count`
131        #[unsafe(method(insertSplitViewItem:atIndex:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn insertSplitViewItem_atIndex(
134            &self,
135            split_view_item: &NSSplitViewItem,
136            index: NSInteger,
137        );
138
139        #[cfg(feature = "NSSplitViewItem")]
140        /// Removes a SplitViewItem from the receiver. The layout of the
141        /// `splitView`will be adjusted for its removal. Subclasses must call through
142        /// `-removeSplitViewItem:`to remove a SplitViewItem.
143        ///
144        /// Parameter `splitViewItem`: The SplitViewItem to remove. An exception will be thrown if
145        /// `splitViewItem`is not in the SplitViewController or if it is nil.
146        #[unsafe(method(removeSplitViewItem:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn removeSplitViewItem(&self, split_view_item: &NSSplitViewItem);
149
150        #[cfg(feature = "NSSplitViewItem")]
151        /// Returns the corresponding SplitViewItem for a given child ViewController.
152        ///
153        /// Parameter `viewController`: The ViewController to look up.
154        ///
155        /// Returns: The corresponding SplitViewItem. Returns nil if
156        /// `viewController`is not a child of the SplitViewController.
157        #[unsafe(method(splitViewItemForViewController:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn splitViewItemForViewController(
160            &self,
161            view_controller: &NSViewController,
162        ) -> Option<Retained<NSSplitViewItem>>;
163
164        #[cfg(feature = "objc2-core-foundation")]
165        /// 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.
166        /// Auto-collapsed sidebars will automatically uncollapse if the thickness is increased back to or past the minimum thickness.
167        /// Defaults to
168        /// `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.
169        #[unsafe(method(minimumThicknessForInlineSidebars))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn minimumThicknessForInlineSidebars(&self) -> CGFloat;
172
173        #[cfg(feature = "objc2-core-foundation")]
174        /// Setter for [`minimumThicknessForInlineSidebars`][Self::minimumThicknessForInlineSidebars].
175        #[unsafe(method(setMinimumThicknessForInlineSidebars:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn setMinimumThicknessForInlineSidebars(
178            &self,
179            minimum_thickness_for_inline_sidebars: CGFloat,
180        );
181
182        #[cfg(feature = "NSUserInterfaceValidation")]
183        /// Validates items with an action of `toggleSidebar:` to reflect the status of the sidebar item contained within the receiver.
184        #[unsafe(method(validateUserInterfaceItem:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn validateUserInterfaceItem(
187            &self,
188            item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
189        ) -> bool;
190
191        #[unsafe(method(viewDidLoad))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn viewDidLoad(&self);
194
195        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
196        #[unsafe(method(splitView:canCollapseSubview:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn splitView_canCollapseSubview(
199            &self,
200            split_view: &NSSplitView,
201            subview: &NSView,
202        ) -> bool;
203
204        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
205        #[deprecated = "NSSplitView no longer supports collapsing sections via double-click. This delegate method is never called, and NSSplitViewController's implementation always returns NO."]
206        #[unsafe(method(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex(
209            &self,
210            split_view: &NSSplitView,
211            subview: &NSView,
212            divider_index: NSInteger,
213        ) -> bool;
214
215        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
216        #[unsafe(method(splitView:shouldHideDividerAtIndex:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn splitView_shouldHideDividerAtIndex(
219            &self,
220            split_view: &NSSplitView,
221            divider_index: NSInteger,
222        ) -> bool;
223
224        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
225        #[unsafe(method(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn splitView_effectiveRect_forDrawnRect_ofDividerAtIndex(
228            &self,
229            split_view: &NSSplitView,
230            proposed_effective_rect: NSRect,
231            drawn_rect: NSRect,
232            divider_index: NSInteger,
233        ) -> NSRect;
234
235        #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
236        #[unsafe(method(splitView:additionalEffectiveRectOfDividerAtIndex:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn splitView_additionalEffectiveRectOfDividerAtIndex(
239            &self,
240            split_view: &NSSplitView,
241            divider_index: NSInteger,
242        ) -> NSRect;
243    );
244}
245
246/// Methods declared on superclass `NSViewController`.
247#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
248impl NSSplitViewController {
249    extern_methods!(
250        #[cfg(feature = "NSNib")]
251        #[unsafe(method(initWithNibName:bundle:))]
252        #[unsafe(method_family = init)]
253        pub unsafe fn initWithNibName_bundle(
254            this: Allocated<Self>,
255            nib_name_or_nil: Option<&NSNibName>,
256            nib_bundle_or_nil: Option<&NSBundle>,
257        ) -> Retained<Self>;
258
259        #[unsafe(method(initWithCoder:))]
260        #[unsafe(method_family = init)]
261        pub unsafe fn initWithCoder(
262            this: Allocated<Self>,
263            coder: &NSCoder,
264        ) -> Option<Retained<Self>>;
265    );
266}
267
268/// Methods declared on superclass `NSResponder`.
269#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
270impl NSSplitViewController {
271    extern_methods!(
272        #[unsafe(method(init))]
273        #[unsafe(method_family = init)]
274        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
275    );
276}
277
278/// Methods declared on superclass `NSObject`.
279#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
280impl NSSplitViewController {
281    extern_methods!(
282        #[unsafe(method(new))]
283        #[unsafe(method_family = new)]
284        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
285    );
286}
287
288/// NSSplitViewControllerToggleSidebarAction.
289#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
290impl NSSplitViewController {
291    extern_methods!(
292        /// Animatedly collapses or uncollapses the first sidebar split view item in the receiver. Does nothing if the receiver does not contain any sidebars.
293        #[unsafe(method(toggleSidebar:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn toggleSidebar(&self, sender: Option<&AnyObject>);
296
297        /// Animatedly collapses or uncollapses the first inspector split view item in the receiver. Does nothing if the receiver does not contain any inspectors.
298        #[unsafe(method(toggleInspector:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn toggleInspector(&self, sender: Option<&AnyObject>);
301    );
302}