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