objc2_app_kit/generated/
NSStackView.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/nsstackviewgravity?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSStackViewGravity(pub NSInteger);
17impl NSStackViewGravity {
18    #[doc(alias = "NSStackViewGravityTop")]
19    pub const Top: Self = Self(1);
20    #[doc(alias = "NSStackViewGravityLeading")]
21    pub const Leading: Self = Self(1);
22    #[doc(alias = "NSStackViewGravityCenter")]
23    pub const Center: Self = Self(2);
24    #[doc(alias = "NSStackViewGravityBottom")]
25    pub const Bottom: Self = Self(3);
26    #[doc(alias = "NSStackViewGravityTrailing")]
27    pub const Trailing: Self = Self(3);
28}
29
30unsafe impl Encode for NSStackViewGravity {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for NSStackViewGravity {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewdistribution?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct NSStackViewDistribution(pub NSInteger);
43impl NSStackViewDistribution {
44    /// Default value. NSStackView will not have any special distribution behavior, relying on behavior described by gravity areas and set hugging priorities along the stacking axis.
45    #[doc(alias = "NSStackViewDistributionGravityAreas")]
46    pub const GravityAreas: Self = Self(-1);
47    /// The effective hugging priority in the stacking axis is NSLayoutPriorityRequired, causing the stacked views to tightly fill the container along the stacking axis.
48    #[doc(alias = "NSStackViewDistributionFill")]
49    pub const Fill: Self = Self(0);
50    /// Stacked views will have sizes maintained to be equal as much as possible along the stacking axis. The effective hugging priority in the stacking axis is NSLayoutPriorityRequired.
51    #[doc(alias = "NSStackViewDistributionFillEqually")]
52    pub const FillEqually: Self = Self(1);
53    /// Stacked views will have sizes maintained to be equal, proportionally to their intrinsicContentSizes, as much as possible. The effective hugging priority in the stacking axis is NSLayoutPriorityRequired.
54    #[doc(alias = "NSStackViewDistributionFillProportionally")]
55    pub const FillProportionally: Self = Self(2);
56    /// The space separating stacked views along the stacking axis are maintained to be equal as much as possible while still maintaining the minimum spacing.
57    #[doc(alias = "NSStackViewDistributionEqualSpacing")]
58    pub const EqualSpacing: Self = Self(3);
59    /// Equal center-to-center spacing of the items is maintained as much as possible while still maintaining the minimum spacing between each view.
60    #[doc(alias = "NSStackViewDistributionEqualCentering")]
61    pub const EqualCentering: Self = Self(4);
62}
63
64unsafe impl Encode for NSStackViewDistribution {
65    const ENCODING: Encoding = NSInteger::ENCODING;
66}
67
68unsafe impl RefEncode for NSStackViewDistribution {
69    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
70}
71
72/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewvisibilitypriority?language=objc)
73// NS_TYPED_EXTENSIBLE_ENUM
74pub type NSStackViewVisibilityPriority = c_float;
75
76/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewvisibilityprioritymusthold?language=objc)
77pub static NSStackViewVisibilityPriorityMustHold: NSStackViewVisibilityPriority = 1000 as _;
78
79/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewvisibilityprioritydetachonlyifnecessary?language=objc)
80pub static NSStackViewVisibilityPriorityDetachOnlyIfNecessary: NSStackViewVisibilityPriority =
81    900 as _;
82
83/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewvisibilityprioritynotvisible?language=objc)
84pub static NSStackViewVisibilityPriorityNotVisible: NSStackViewVisibilityPriority = 0 as _;
85
86/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewspacingusedefault?language=objc)
87#[cfg(feature = "objc2-core-foundation")]
88pub static NSStackViewSpacingUseDefault: CGFloat = c_float::MAX as _;
89
90extern_class!(
91    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackview?language=objc)
92    #[unsafe(super(NSView, NSResponder, NSObject))]
93    #[derive(Debug, PartialEq, Eq, Hash)]
94    #[cfg(all(feature = "NSResponder", feature = "NSView"))]
95    pub struct NSStackView;
96);
97
98#[cfg(all(
99    feature = "NSAccessibilityProtocols",
100    feature = "NSResponder",
101    feature = "NSView"
102))]
103extern_conformance!(
104    unsafe impl NSAccessibility for NSStackView {}
105);
106
107#[cfg(all(
108    feature = "NSAccessibilityProtocols",
109    feature = "NSResponder",
110    feature = "NSView"
111))]
112extern_conformance!(
113    unsafe impl NSAccessibilityElementProtocol for NSStackView {}
114);
115
116#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
117extern_conformance!(
118    unsafe impl NSAnimatablePropertyContainer for NSStackView {}
119);
120
121#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
122extern_conformance!(
123    unsafe impl NSAppearanceCustomization for NSStackView {}
124);
125
126#[cfg(all(feature = "NSResponder", feature = "NSView"))]
127extern_conformance!(
128    unsafe impl NSCoding for NSStackView {}
129);
130
131#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
132extern_conformance!(
133    unsafe impl NSDraggingDestination for NSStackView {}
134);
135
136#[cfg(all(feature = "NSResponder", feature = "NSView"))]
137extern_conformance!(
138    unsafe impl NSObjectProtocol for NSStackView {}
139);
140
141#[cfg(all(
142    feature = "NSResponder",
143    feature = "NSUserInterfaceItemIdentification",
144    feature = "NSView"
145))]
146extern_conformance!(
147    unsafe impl NSUserInterfaceItemIdentification for NSStackView {}
148);
149
150#[cfg(all(feature = "NSResponder", feature = "NSView"))]
151impl NSStackView {
152    extern_methods!(
153        #[unsafe(method(stackViewWithViews:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn stackViewWithViews(
156            views: &NSArray<NSView>,
157            mtm: MainThreadMarker,
158        ) -> Retained<Self>;
159
160        #[unsafe(method(delegate))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSStackViewDelegate>>>;
163
164        /// This is a [weak property][objc2::topics::weak_property].
165        /// Setter for [`delegate`][Self::delegate].
166        #[unsafe(method(setDelegate:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setDelegate(
169            &self,
170            delegate: Option<&ProtocolObject<dyn NSStackViewDelegate>>,
171        );
172
173        #[cfg(feature = "NSUserInterfaceLayout")]
174        /// Orientation of the StackView, defaults to NSUserInterfaceLayoutOrientationHorizontal
175        #[unsafe(method(orientation))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn orientation(&self) -> NSUserInterfaceLayoutOrientation;
178
179        #[cfg(feature = "NSUserInterfaceLayout")]
180        /// Setter for [`orientation`][Self::orientation].
181        #[unsafe(method(setOrientation:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn setOrientation(&self, orientation: NSUserInterfaceLayoutOrientation);
184
185        #[cfg(feature = "NSLayoutConstraint")]
186        /// Describes how subviews are aligned within the StackView, defaults to `NSLayoutAttributeCenterY` for horizontal stacks, `NSLayoutAttributeCenterX` for vertical stacks. Setting `NSLayoutAttributeNotAnAttribute` will cause the internal alignment constraints to not be created, and could result in an ambiguous layout. Setting an inapplicable attribute for the set orientation will result in the alignment being ignored (similar to its handling with NSLayoutAttributeNotAnAttribute). The alignment constraints are established at a priority of `NSLayoutPriorityDefaultLow` and are overridable for individual views using external constraints.
187        #[unsafe(method(alignment))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn alignment(&self) -> NSLayoutAttribute;
190
191        #[cfg(feature = "NSLayoutConstraint")]
192        /// Setter for [`alignment`][Self::alignment].
193        #[unsafe(method(setAlignment:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setAlignment(&self, alignment: NSLayoutAttribute);
196
197        /// Default padding inside the StackView, around all of the subviews.
198        #[unsafe(method(edgeInsets))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn edgeInsets(&self) -> NSEdgeInsets;
201
202        /// Setter for [`edgeInsets`][Self::edgeInsets].
203        #[unsafe(method(setEdgeInsets:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setEdgeInsets(&self, edge_insets: NSEdgeInsets);
206
207        /// The spacing and sizing distribution of stacked views along the primary axis. Defaults to GravityAreas.
208        #[unsafe(method(distribution))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn distribution(&self) -> NSStackViewDistribution;
211
212        /// Setter for [`distribution`][Self::distribution].
213        #[unsafe(method(setDistribution:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setDistribution(&self, distribution: NSStackViewDistribution);
216
217        #[cfg(feature = "objc2-core-foundation")]
218        /// Default (minimum) spacing between each view
219        #[unsafe(method(spacing))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn spacing(&self) -> CGFloat;
222
223        #[cfg(feature = "objc2-core-foundation")]
224        /// Setter for [`spacing`][Self::spacing].
225        #[unsafe(method(setSpacing:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn setSpacing(&self, spacing: CGFloat);
228
229        #[cfg(feature = "objc2-core-foundation")]
230        #[unsafe(method(setCustomSpacing:afterView:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn setCustomSpacing_afterView(&self, spacing: CGFloat, view: &NSView);
233
234        #[cfg(feature = "objc2-core-foundation")]
235        #[unsafe(method(customSpacingAfterView:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn customSpacingAfterView(&self, view: &NSView) -> CGFloat;
238
239        /// If YES, when a stacked view's `hidden` property is set to YES, the view will be detached from the stack and reattached when set to NO. Similarly, if the view has a lowered visibility priority and is detached from the stack view, it will be set as `hidden` rather than removed from the view hierarchy. Defaults to YES for apps linked on the 10.11 SDK or later.
240        #[unsafe(method(detachesHiddenViews))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn detachesHiddenViews(&self) -> bool;
243
244        /// Setter for [`detachesHiddenViews`][Self::detachesHiddenViews].
245        #[unsafe(method(setDetachesHiddenViews:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setDetachesHiddenViews(&self, detaches_hidden_views: bool);
248
249        /// The list of views that are arranged in a stack by the receiver. They are a subset of
250        /// `-subviews,`with potential difference in ordering.
251        #[unsafe(method(arrangedSubviews))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn arrangedSubviews(&self) -> Retained<NSArray<NSView>>;
254
255        /// Adds a view to the end of the arrangedSubviews list. If the view is not a subview of the receiver, it will be added as one.
256        #[unsafe(method(addArrangedSubview:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn addArrangedSubview(&self, view: &NSView);
259
260        /// Adds a view to the arrangedSubviews list at a specific index.
261        /// If the view is already in the arrangedSubviews list, it will move the view to the specified index (but not change the subview index).
262        /// If the view is not a subview of the receiver, it will be added as one (not necessarily at the same index).
263        #[unsafe(method(insertArrangedSubview:atIndex:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn insertArrangedSubview_atIndex(&self, view: &NSView, index: NSInteger);
266
267        /// Removes a subview from the list of arranged subviews without removing it as a subview of the receiver.
268        /// Removing the view as a subview (either by -[view removeFromSuperview] or setting the receiver's subviews) will automatically remove it as an arranged subview.
269        #[unsafe(method(removeArrangedSubview:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn removeArrangedSubview(&self, view: &NSView);
272
273        /// The arrangedSubviews that are currently detached/hidden.
274        #[unsafe(method(detachedViews))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn detachedViews(&self) -> Retained<NSArray<NSView>>;
277
278        #[unsafe(method(setVisibilityPriority:forView:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn setVisibilityPriority_forView(
281            &self,
282            priority: NSStackViewVisibilityPriority,
283            view: &NSView,
284        );
285
286        #[unsafe(method(visibilityPriorityForView:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn visibilityPriorityForView(
289            &self,
290            view: &NSView,
291        ) -> NSStackViewVisibilityPriority;
292
293        #[cfg(feature = "NSLayoutConstraint")]
294        #[unsafe(method(clippingResistancePriorityForOrientation:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn clippingResistancePriorityForOrientation(
297            &self,
298            orientation: NSLayoutConstraintOrientation,
299        ) -> NSLayoutPriority;
300
301        #[cfg(feature = "NSLayoutConstraint")]
302        #[unsafe(method(setClippingResistancePriority:forOrientation:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn setClippingResistancePriority_forOrientation(
305            &self,
306            clipping_resistance_priority: NSLayoutPriority,
307            orientation: NSLayoutConstraintOrientation,
308        );
309
310        #[cfg(feature = "NSLayoutConstraint")]
311        #[unsafe(method(huggingPriorityForOrientation:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn huggingPriorityForOrientation(
314            &self,
315            orientation: NSLayoutConstraintOrientation,
316        ) -> NSLayoutPriority;
317
318        #[cfg(feature = "NSLayoutConstraint")]
319        #[unsafe(method(setHuggingPriority:forOrientation:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn setHuggingPriority_forOrientation(
322            &self,
323            hugging_priority: NSLayoutPriority,
324            orientation: NSLayoutConstraintOrientation,
325        );
326    );
327}
328
329/// Methods declared on superclass `NSView`.
330#[cfg(all(feature = "NSResponder", feature = "NSView"))]
331impl NSStackView {
332    extern_methods!(
333        #[unsafe(method(initWithFrame:))]
334        #[unsafe(method_family = init)]
335        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
336
337        #[unsafe(method(initWithCoder:))]
338        #[unsafe(method_family = init)]
339        pub unsafe fn initWithCoder(
340            this: Allocated<Self>,
341            coder: &NSCoder,
342        ) -> Option<Retained<Self>>;
343    );
344}
345
346/// Methods declared on superclass `NSResponder`.
347#[cfg(all(feature = "NSResponder", feature = "NSView"))]
348impl NSStackView {
349    extern_methods!(
350        #[unsafe(method(init))]
351        #[unsafe(method_family = init)]
352        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
353    );
354}
355
356/// Methods declared on superclass `NSObject`.
357#[cfg(all(feature = "NSResponder", feature = "NSView"))]
358impl NSStackView {
359    extern_methods!(
360        #[unsafe(method(new))]
361        #[unsafe(method_family = new)]
362        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
363    );
364}
365
366extern_protocol!(
367    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewdelegate?language=objc)
368    pub unsafe trait NSStackViewDelegate: NSObjectProtocol + MainThreadOnly {
369        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
370        #[optional]
371        #[unsafe(method(stackView:willDetachViews:))]
372        #[unsafe(method_family = none)]
373        unsafe fn stackView_willDetachViews(
374            &self,
375            stack_view: &NSStackView,
376            views: &NSArray<NSView>,
377        );
378
379        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
380        #[optional]
381        #[unsafe(method(stackView:didReattachViews:))]
382        #[unsafe(method_family = none)]
383        unsafe fn stackView_didReattachViews(
384            &self,
385            stack_view: &NSStackView,
386            views: &NSArray<NSView>,
387        );
388    }
389);
390
391/// NSStackViewGravityAreas.
392#[cfg(all(feature = "NSResponder", feature = "NSView"))]
393impl NSStackView {
394    extern_methods!(
395        #[unsafe(method(addView:inGravity:))]
396        #[unsafe(method_family = none)]
397        pub unsafe fn addView_inGravity(&self, view: &NSView, gravity: NSStackViewGravity);
398
399        #[unsafe(method(insertView:atIndex:inGravity:))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn insertView_atIndex_inGravity(
402            &self,
403            view: &NSView,
404            index: NSUInteger,
405            gravity: NSStackViewGravity,
406        );
407
408        #[unsafe(method(removeView:))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn removeView(&self, view: &NSView);
411
412        #[unsafe(method(viewsInGravity:))]
413        #[unsafe(method_family = none)]
414        pub unsafe fn viewsInGravity(
415            &self,
416            gravity: NSStackViewGravity,
417        ) -> Retained<NSArray<NSView>>;
418
419        #[unsafe(method(setViews:inGravity:))]
420        #[unsafe(method_family = none)]
421        pub unsafe fn setViews_inGravity(
422            &self,
423            views: &NSArray<NSView>,
424            gravity: NSStackViewGravity,
425        );
426
427        #[unsafe(method(views))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn views(&self) -> Retained<NSArray<NSView>>;
430    );
431}
432
433/// NSStackViewDeprecated.
434#[cfg(all(feature = "NSResponder", feature = "NSView"))]
435impl NSStackView {
436    extern_methods!(
437        #[deprecated = "Set -distribution to NSStackViewDistributionEqualSpacing instead."]
438        #[unsafe(method(hasEqualSpacing))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn hasEqualSpacing(&self) -> bool;
441
442        /// Setter for [`hasEqualSpacing`][Self::hasEqualSpacing].
443        #[deprecated = "Set -distribution to NSStackViewDistributionEqualSpacing instead."]
444        #[unsafe(method(setHasEqualSpacing:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn setHasEqualSpacing(&self, has_equal_spacing: bool);
447    );
448}