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 receivers '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 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 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 fn splitViewItems(&self) -> Retained<NSArray<NSSplitViewItem>>;
117
118 #[cfg(feature = "NSSplitViewItem")]
119 /// Setter for [`splitViewItems`][Self::splitViewItems].
120 ///
121 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
122 #[unsafe(method(setSplitViewItems:))]
123 #[unsafe(method_family = none)]
124 pub fn setSplitViewItems(&self, split_view_items: &NSArray<NSSplitViewItem>);
125
126 #[cfg(feature = "NSSplitViewItem")]
127 /// 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:.
128 ///
129 /// 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.
130 #[unsafe(method(addSplitViewItem:))]
131 #[unsafe(method_family = none)]
132 pub fn addSplitViewItem(&self, split_view_item: &NSSplitViewItem);
133
134 #[cfg(feature = "NSSplitViewItem")]
135 /// 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
136 /// `splitView.`Subclasses must call through
137 /// `-insertSplitViewItem:atIndex:`to add a SplitViewItem.
138 ///
139 /// Parameter `splitViewItem`: The SplitViewItem to add. It must have a
140 /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if splitViewItem is nil.
141 ///
142 /// Parameter `index`: The index to add the SplitViewItem at. Will throw an exception if
143 /// `index`<
144 /// 0 or
145 /// `index`>
146 /// `splitViewItems.count`
147 #[unsafe(method(insertSplitViewItem:atIndex:))]
148 #[unsafe(method_family = none)]
149 pub fn insertSplitViewItem_atIndex(
150 &self,
151 split_view_item: &NSSplitViewItem,
152 index: NSInteger,
153 );
154
155 #[cfg(feature = "NSSplitViewItem")]
156 /// Removes a SplitViewItem from the receiver. The layout of the
157 /// `splitView`will be adjusted for its removal. Subclasses must call through
158 /// `-removeSplitViewItem:`to remove a SplitViewItem.
159 ///
160 /// Parameter `splitViewItem`: The SplitViewItem to remove. An exception will be thrown if
161 /// `splitViewItem`is not in the SplitViewController or if it is nil.
162 #[unsafe(method(removeSplitViewItem:))]
163 #[unsafe(method_family = none)]
164 pub fn removeSplitViewItem(&self, split_view_item: &NSSplitViewItem);
165
166 #[cfg(feature = "NSSplitViewItem")]
167 /// Returns the corresponding SplitViewItem for a given child ViewController.
168 ///
169 /// Parameter `viewController`: The ViewController to look up.
170 ///
171 /// Returns: The corresponding SplitViewItem. Returns nil if
172 /// `viewController`is not a child of the SplitViewController.
173 #[unsafe(method(splitViewItemForViewController:))]
174 #[unsafe(method_family = none)]
175 pub fn splitViewItemForViewController(
176 &self,
177 view_controller: &NSViewController,
178 ) -> Option<Retained<NSSplitViewItem>>;
179
180 #[cfg(feature = "objc2-core-foundation")]
181 /// 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.
182 /// Auto-collapsed sidebars will automatically uncollapse if the thickness is increased back to or past the minimum thickness.
183 /// Defaults to
184 /// `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.
185 #[unsafe(method(minimumThicknessForInlineSidebars))]
186 #[unsafe(method_family = none)]
187 pub fn minimumThicknessForInlineSidebars(&self) -> CGFloat;
188
189 #[cfg(feature = "objc2-core-foundation")]
190 /// Setter for [`minimumThicknessForInlineSidebars`][Self::minimumThicknessForInlineSidebars].
191 #[unsafe(method(setMinimumThicknessForInlineSidebars:))]
192 #[unsafe(method_family = none)]
193 pub fn setMinimumThicknessForInlineSidebars(
194 &self,
195 minimum_thickness_for_inline_sidebars: CGFloat,
196 );
197
198 #[cfg(feature = "NSUserInterfaceValidation")]
199 /// Validates items with an action of `toggleSidebar:` to reflect the status of the sidebar item contained within the receiver.
200 #[unsafe(method(validateUserInterfaceItem:))]
201 #[unsafe(method_family = none)]
202 pub fn validateUserInterfaceItem(
203 &self,
204 item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
205 ) -> bool;
206
207 #[unsafe(method(viewDidLoad))]
208 #[unsafe(method_family = none)]
209 pub fn viewDidLoad(&self);
210
211 #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
212 #[unsafe(method(splitView:canCollapseSubview:))]
213 #[unsafe(method_family = none)]
214 pub fn splitView_canCollapseSubview(
215 &self,
216 split_view: &NSSplitView,
217 subview: &NSView,
218 ) -> bool;
219
220 #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
221 #[deprecated = "NSSplitView no longer supports collapsing sections via double-click. This delegate method is never called, and NSSplitViewController's implementation always returns NO."]
222 #[unsafe(method(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:))]
223 #[unsafe(method_family = none)]
224 pub fn splitView_shouldCollapseSubview_forDoubleClickOnDividerAtIndex(
225 &self,
226 split_view: &NSSplitView,
227 subview: &NSView,
228 divider_index: NSInteger,
229 ) -> bool;
230
231 #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
232 #[unsafe(method(splitView:shouldHideDividerAtIndex:))]
233 #[unsafe(method_family = none)]
234 pub fn splitView_shouldHideDividerAtIndex(
235 &self,
236 split_view: &NSSplitView,
237 divider_index: NSInteger,
238 ) -> bool;
239
240 #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
241 #[unsafe(method(splitView:effectiveRect:forDrawnRect:ofDividerAtIndex:))]
242 #[unsafe(method_family = none)]
243 pub fn splitView_effectiveRect_forDrawnRect_ofDividerAtIndex(
244 &self,
245 split_view: &NSSplitView,
246 proposed_effective_rect: NSRect,
247 drawn_rect: NSRect,
248 divider_index: NSInteger,
249 ) -> NSRect;
250
251 #[cfg(all(feature = "NSSplitView", feature = "NSView"))]
252 #[unsafe(method(splitView:additionalEffectiveRectOfDividerAtIndex:))]
253 #[unsafe(method_family = none)]
254 pub fn splitView_additionalEffectiveRectOfDividerAtIndex(
255 &self,
256 split_view: &NSSplitView,
257 divider_index: NSInteger,
258 ) -> NSRect;
259 );
260}
261
262/// Methods declared on superclass `NSViewController`.
263#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
264impl NSSplitViewController {
265 extern_methods!(
266 #[cfg(feature = "NSNib")]
267 #[unsafe(method(initWithNibName:bundle:))]
268 #[unsafe(method_family = init)]
269 pub fn initWithNibName_bundle(
270 this: Allocated<Self>,
271 nib_name_or_nil: Option<&NSNibName>,
272 nib_bundle_or_nil: Option<&NSBundle>,
273 ) -> Retained<Self>;
274
275 /// # Safety
276 ///
277 /// `coder` possibly has further requirements.
278 #[unsafe(method(initWithCoder:))]
279 #[unsafe(method_family = init)]
280 pub unsafe fn initWithCoder(
281 this: Allocated<Self>,
282 coder: &NSCoder,
283 ) -> Option<Retained<Self>>;
284 );
285}
286
287/// Methods declared on superclass `NSResponder`.
288#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
289impl NSSplitViewController {
290 extern_methods!(
291 #[unsafe(method(init))]
292 #[unsafe(method_family = init)]
293 pub fn init(this: Allocated<Self>) -> Retained<Self>;
294 );
295}
296
297/// Methods declared on superclass `NSObject`.
298#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
299impl NSSplitViewController {
300 extern_methods!(
301 #[unsafe(method(new))]
302 #[unsafe(method_family = new)]
303 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
304 );
305}
306
307/// NSSplitViewControllerToggleSidebarAction.
308#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
309impl NSSplitViewController {
310 extern_methods!(
311 /// Animatedly collapses or uncollapses the first sidebar split view item in the receiver. Does nothing if the receiver does not contain any sidebars.
312 ///
313 /// # Safety
314 ///
315 /// `sender` should be of the correct type.
316 #[unsafe(method(toggleSidebar:))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn toggleSidebar(&self, sender: Option<&AnyObject>);
319
320 /// Animatedly collapses or uncollapses the first inspector split view item in the receiver. Does nothing if the receiver does not contain any inspectors.
321 ///
322 /// # Safety
323 ///
324 /// `sender` should be of the correct type.
325 #[unsafe(method(toggleInspector:))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn toggleInspector(&self, sender: Option<&AnyObject>);
328 );
329}