1use 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#[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#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct NSStackViewDistribution(pub NSInteger);
43impl NSStackViewDistribution {
44 #[doc(alias = "NSStackViewDistributionGravityAreas")]
46 pub const GravityAreas: Self = Self(-1);
47 #[doc(alias = "NSStackViewDistributionFill")]
49 pub const Fill: Self = Self(0);
50 #[doc(alias = "NSStackViewDistributionFillEqually")]
52 pub const FillEqually: Self = Self(1);
53 #[doc(alias = "NSStackViewDistributionFillProportionally")]
55 pub const FillProportionally: Self = Self(2);
56 #[doc(alias = "NSStackViewDistributionEqualSpacing")]
58 pub const EqualSpacing: Self = Self(3);
59 #[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
72pub type NSStackViewVisibilityPriority = c_float;
75
76pub static NSStackViewVisibilityPriorityMustHold: NSStackViewVisibilityPriority = 1000 as _;
78
79pub static NSStackViewVisibilityPriorityDetachOnlyIfNecessary: NSStackViewVisibilityPriority =
81 900 as _;
82
83pub static NSStackViewVisibilityPriorityNotVisible: NSStackViewVisibilityPriority = 0 as _;
85
86#[cfg(feature = "objc2-core-foundation")]
88pub static NSStackViewSpacingUseDefault: CGFloat = c_float::MAX as _;
89
90extern_class!(
91 #[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 #[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 #[unsafe(method(orientation))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn orientation(&self) -> NSUserInterfaceLayoutOrientation;
178
179 #[cfg(feature = "NSUserInterfaceLayout")]
180 #[unsafe(method(setOrientation:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn setOrientation(&self, orientation: NSUserInterfaceLayoutOrientation);
184
185 #[cfg(feature = "NSLayoutConstraint")]
186 #[unsafe(method(alignment))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn alignment(&self) -> NSLayoutAttribute;
190
191 #[cfg(feature = "NSLayoutConstraint")]
192 #[unsafe(method(setAlignment:))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn setAlignment(&self, alignment: NSLayoutAttribute);
196
197 #[unsafe(method(edgeInsets))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn edgeInsets(&self) -> NSEdgeInsets;
201
202 #[unsafe(method(setEdgeInsets:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn setEdgeInsets(&self, edge_insets: NSEdgeInsets);
206
207 #[unsafe(method(distribution))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn distribution(&self) -> NSStackViewDistribution;
211
212 #[unsafe(method(setDistribution:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn setDistribution(&self, distribution: NSStackViewDistribution);
216
217 #[cfg(feature = "objc2-core-foundation")]
218 #[unsafe(method(spacing))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn spacing(&self) -> CGFloat;
222
223 #[cfg(feature = "objc2-core-foundation")]
224 #[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 #[unsafe(method(detachesHiddenViews))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn detachesHiddenViews(&self) -> bool;
243
244 #[unsafe(method(setDetachesHiddenViews:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setDetachesHiddenViews(&self, detaches_hidden_views: bool);
248
249 #[unsafe(method(arrangedSubviews))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn arrangedSubviews(&self) -> Retained<NSArray<NSView>>;
254
255 #[unsafe(method(addArrangedSubview:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn addArrangedSubview(&self, view: &NSView);
259
260 #[unsafe(method(insertArrangedSubview:atIndex:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn insertArrangedSubview_atIndex(&self, view: &NSView, index: NSInteger);
266
267 #[unsafe(method(removeArrangedSubview:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn removeArrangedSubview(&self, view: &NSView);
272
273 #[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#[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#[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#[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 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#[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#[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 #[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}