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 fn stackViewWithViews(views: &NSArray<NSView>, mtm: MainThreadMarker)
156            -> Retained<Self>;
157
158        #[unsafe(method(delegate))]
159        #[unsafe(method_family = none)]
160        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSStackViewDelegate>>>;
161
162        /// Setter for [`delegate`][Self::delegate].
163        ///
164        /// This is a [weak property][objc2::topics::weak_property].
165        #[unsafe(method(setDelegate:))]
166        #[unsafe(method_family = none)]
167        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSStackViewDelegate>>);
168
169        #[cfg(feature = "NSUserInterfaceLayout")]
170        /// Orientation of the StackView, defaults to NSUserInterfaceLayoutOrientationHorizontal
171        #[unsafe(method(orientation))]
172        #[unsafe(method_family = none)]
173        pub fn orientation(&self) -> NSUserInterfaceLayoutOrientation;
174
175        #[cfg(feature = "NSUserInterfaceLayout")]
176        /// Setter for [`orientation`][Self::orientation].
177        #[unsafe(method(setOrientation:))]
178        #[unsafe(method_family = none)]
179        pub fn setOrientation(&self, orientation: NSUserInterfaceLayoutOrientation);
180
181        #[cfg(feature = "NSLayoutConstraint")]
182        /// 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.
183        #[unsafe(method(alignment))]
184        #[unsafe(method_family = none)]
185        pub fn alignment(&self) -> NSLayoutAttribute;
186
187        #[cfg(feature = "NSLayoutConstraint")]
188        /// Setter for [`alignment`][Self::alignment].
189        #[unsafe(method(setAlignment:))]
190        #[unsafe(method_family = none)]
191        pub fn setAlignment(&self, alignment: NSLayoutAttribute);
192
193        /// Default padding inside the StackView, around all of the subviews.
194        #[unsafe(method(edgeInsets))]
195        #[unsafe(method_family = none)]
196        pub fn edgeInsets(&self) -> NSEdgeInsets;
197
198        /// Setter for [`edgeInsets`][Self::edgeInsets].
199        #[unsafe(method(setEdgeInsets:))]
200        #[unsafe(method_family = none)]
201        pub fn setEdgeInsets(&self, edge_insets: NSEdgeInsets);
202
203        /// The spacing and sizing distribution of stacked views along the primary axis. Defaults to GravityAreas.
204        #[unsafe(method(distribution))]
205        #[unsafe(method_family = none)]
206        pub fn distribution(&self) -> NSStackViewDistribution;
207
208        /// Setter for [`distribution`][Self::distribution].
209        #[unsafe(method(setDistribution:))]
210        #[unsafe(method_family = none)]
211        pub fn setDistribution(&self, distribution: NSStackViewDistribution);
212
213        #[cfg(feature = "objc2-core-foundation")]
214        /// Default (minimum) spacing between each view
215        #[unsafe(method(spacing))]
216        #[unsafe(method_family = none)]
217        pub fn spacing(&self) -> CGFloat;
218
219        #[cfg(feature = "objc2-core-foundation")]
220        /// Setter for [`spacing`][Self::spacing].
221        #[unsafe(method(setSpacing:))]
222        #[unsafe(method_family = none)]
223        pub fn setSpacing(&self, spacing: CGFloat);
224
225        #[cfg(feature = "objc2-core-foundation")]
226        #[unsafe(method(setCustomSpacing:afterView:))]
227        #[unsafe(method_family = none)]
228        pub fn setCustomSpacing_afterView(&self, spacing: CGFloat, view: &NSView);
229
230        #[cfg(feature = "objc2-core-foundation")]
231        #[unsafe(method(customSpacingAfterView:))]
232        #[unsafe(method_family = none)]
233        pub fn customSpacingAfterView(&self, view: &NSView) -> CGFloat;
234
235        /// 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.
236        #[unsafe(method(detachesHiddenViews))]
237        #[unsafe(method_family = none)]
238        pub fn detachesHiddenViews(&self) -> bool;
239
240        /// Setter for [`detachesHiddenViews`][Self::detachesHiddenViews].
241        #[unsafe(method(setDetachesHiddenViews:))]
242        #[unsafe(method_family = none)]
243        pub fn setDetachesHiddenViews(&self, detaches_hidden_views: bool);
244
245        /// The list of views that are arranged in a stack by the receiver. They are a subset of
246        /// `-subviews,`with potential difference in ordering.
247        #[unsafe(method(arrangedSubviews))]
248        #[unsafe(method_family = none)]
249        pub fn arrangedSubviews(&self) -> Retained<NSArray<NSView>>;
250
251        /// 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.
252        #[unsafe(method(addArrangedSubview:))]
253        #[unsafe(method_family = none)]
254        pub fn addArrangedSubview(&self, view: &NSView);
255
256        /// Adds a view to the arrangedSubviews list at a specific index.
257        /// If the view is already in the arrangedSubviews list, it will move the view to the specified index (but not change the subview index).
258        /// If the view is not a subview of the receiver, it will be added as one (not necessarily at the same index).
259        #[unsafe(method(insertArrangedSubview:atIndex:))]
260        #[unsafe(method_family = none)]
261        pub fn insertArrangedSubview_atIndex(&self, view: &NSView, index: NSInteger);
262
263        /// Removes a subview from the list of arranged subviews without removing it as a subview of the receiver.
264        /// Removing the view as a subview (either by -[view removeFromSuperview] or setting the receiver's subviews) will automatically remove it as an arranged subview.
265        #[unsafe(method(removeArrangedSubview:))]
266        #[unsafe(method_family = none)]
267        pub fn removeArrangedSubview(&self, view: &NSView);
268
269        /// The arrangedSubviews that are currently detached/hidden.
270        #[unsafe(method(detachedViews))]
271        #[unsafe(method_family = none)]
272        pub fn detachedViews(&self) -> Retained<NSArray<NSView>>;
273
274        #[unsafe(method(setVisibilityPriority:forView:))]
275        #[unsafe(method_family = none)]
276        pub fn setVisibilityPriority_forView(
277            &self,
278            priority: NSStackViewVisibilityPriority,
279            view: &NSView,
280        );
281
282        #[unsafe(method(visibilityPriorityForView:))]
283        #[unsafe(method_family = none)]
284        pub fn visibilityPriorityForView(&self, view: &NSView) -> NSStackViewVisibilityPriority;
285
286        #[cfg(feature = "NSLayoutConstraint")]
287        #[unsafe(method(clippingResistancePriorityForOrientation:))]
288        #[unsafe(method_family = none)]
289        pub fn clippingResistancePriorityForOrientation(
290            &self,
291            orientation: NSLayoutConstraintOrientation,
292        ) -> NSLayoutPriority;
293
294        #[cfg(feature = "NSLayoutConstraint")]
295        #[unsafe(method(setClippingResistancePriority:forOrientation:))]
296        #[unsafe(method_family = none)]
297        pub fn setClippingResistancePriority_forOrientation(
298            &self,
299            clipping_resistance_priority: NSLayoutPriority,
300            orientation: NSLayoutConstraintOrientation,
301        );
302
303        #[cfg(feature = "NSLayoutConstraint")]
304        #[unsafe(method(huggingPriorityForOrientation:))]
305        #[unsafe(method_family = none)]
306        pub fn huggingPriorityForOrientation(
307            &self,
308            orientation: NSLayoutConstraintOrientation,
309        ) -> NSLayoutPriority;
310
311        #[cfg(feature = "NSLayoutConstraint")]
312        #[unsafe(method(setHuggingPriority:forOrientation:))]
313        #[unsafe(method_family = none)]
314        pub fn setHuggingPriority_forOrientation(
315            &self,
316            hugging_priority: NSLayoutPriority,
317            orientation: NSLayoutConstraintOrientation,
318        );
319    );
320}
321
322/// Methods declared on superclass `NSView`.
323#[cfg(all(feature = "NSResponder", feature = "NSView"))]
324impl NSStackView {
325    extern_methods!(
326        #[unsafe(method(initWithFrame:))]
327        #[unsafe(method_family = init)]
328        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
329
330        /// # Safety
331        ///
332        /// `coder` possibly has further requirements.
333        #[unsafe(method(initWithCoder:))]
334        #[unsafe(method_family = init)]
335        pub unsafe fn initWithCoder(
336            this: Allocated<Self>,
337            coder: &NSCoder,
338        ) -> Option<Retained<Self>>;
339    );
340}
341
342/// Methods declared on superclass `NSResponder`.
343#[cfg(all(feature = "NSResponder", feature = "NSView"))]
344impl NSStackView {
345    extern_methods!(
346        #[unsafe(method(init))]
347        #[unsafe(method_family = init)]
348        pub fn init(this: Allocated<Self>) -> Retained<Self>;
349    );
350}
351
352/// Methods declared on superclass `NSObject`.
353#[cfg(all(feature = "NSResponder", feature = "NSView"))]
354impl NSStackView {
355    extern_methods!(
356        #[unsafe(method(new))]
357        #[unsafe(method_family = new)]
358        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
359    );
360}
361
362extern_protocol!(
363    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstackviewdelegate?language=objc)
364    pub unsafe trait NSStackViewDelegate: NSObjectProtocol + MainThreadOnly {
365        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
366        #[optional]
367        #[unsafe(method(stackView:willDetachViews:))]
368        #[unsafe(method_family = none)]
369        fn stackView_willDetachViews(&self, stack_view: &NSStackView, views: &NSArray<NSView>);
370
371        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
372        #[optional]
373        #[unsafe(method(stackView:didReattachViews:))]
374        #[unsafe(method_family = none)]
375        fn stackView_didReattachViews(&self, stack_view: &NSStackView, views: &NSArray<NSView>);
376    }
377);
378
379/// NSStackViewGravityAreas.
380#[cfg(all(feature = "NSResponder", feature = "NSView"))]
381impl NSStackView {
382    extern_methods!(
383        #[unsafe(method(addView:inGravity:))]
384        #[unsafe(method_family = none)]
385        pub fn addView_inGravity(&self, view: &NSView, gravity: NSStackViewGravity);
386
387        #[unsafe(method(insertView:atIndex:inGravity:))]
388        #[unsafe(method_family = none)]
389        pub fn insertView_atIndex_inGravity(
390            &self,
391            view: &NSView,
392            index: NSUInteger,
393            gravity: NSStackViewGravity,
394        );
395
396        #[unsafe(method(removeView:))]
397        #[unsafe(method_family = none)]
398        pub fn removeView(&self, view: &NSView);
399
400        #[unsafe(method(viewsInGravity:))]
401        #[unsafe(method_family = none)]
402        pub fn viewsInGravity(&self, gravity: NSStackViewGravity) -> Retained<NSArray<NSView>>;
403
404        #[unsafe(method(setViews:inGravity:))]
405        #[unsafe(method_family = none)]
406        pub fn setViews_inGravity(&self, views: &NSArray<NSView>, gravity: NSStackViewGravity);
407
408        #[unsafe(method(views))]
409        #[unsafe(method_family = none)]
410        pub fn views(&self) -> Retained<NSArray<NSView>>;
411    );
412}
413
414/// NSStackViewDeprecated.
415#[cfg(all(feature = "NSResponder", feature = "NSView"))]
416impl NSStackView {
417    extern_methods!(
418        #[deprecated = "Set -distribution to NSStackViewDistributionEqualSpacing instead."]
419        #[unsafe(method(hasEqualSpacing))]
420        #[unsafe(method_family = none)]
421        pub fn hasEqualSpacing(&self) -> bool;
422
423        /// Setter for [`hasEqualSpacing`][Self::hasEqualSpacing].
424        #[deprecated = "Set -distribution to NSStackViewDistributionEqualSpacing instead."]
425        #[unsafe(method(setHasEqualSpacing:))]
426        #[unsafe(method_family = none)]
427        pub fn setHasEqualSpacing(&self, has_equal_spacing: bool);
428    );
429}