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