objc2_ui_kit/generated/
UITraitCollection.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
12extern_class!(
13    /// A trait collection encapsulates the system traits of an interface's environment.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitcollection?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct UITraitCollection;
19);
20
21unsafe impl Send for UITraitCollection {}
22
23unsafe impl Sync for UITraitCollection {}
24
25extern_conformance!(
26    unsafe impl NSCoding for UITraitCollection {}
27);
28
29extern_conformance!(
30    unsafe impl NSCopying for UITraitCollection {}
31);
32
33unsafe impl CopyingHelper for UITraitCollection {
34    type Result = Self;
35}
36
37extern_conformance!(
38    unsafe impl NSObjectProtocol for UITraitCollection {}
39);
40
41extern_conformance!(
42    unsafe impl NSSecureCoding for UITraitCollection {}
43);
44
45impl UITraitCollection {
46    extern_methods!(
47        #[unsafe(method(init))]
48        #[unsafe(method_family = init)]
49        pub fn init(this: Allocated<Self>) -> Retained<Self>;
50
51        /// # Safety
52        ///
53        /// `coder` possibly has further requirements.
54        #[unsafe(method(initWithCoder:))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn initWithCoder(
57            this: Allocated<Self>,
58            coder: &NSCoder,
59        ) -> Option<Retained<Self>>;
60
61        #[deprecated = "Compare values for specific traits in the trait collections instead"]
62        #[unsafe(method(containsTraitsInCollection:))]
63        #[unsafe(method_family = none)]
64        pub fn containsTraitsInCollection(&self, r#trait: Option<&UITraitCollection>) -> bool;
65
66        #[deprecated = "Use +[UITraitCollection traitCollectionWithTraits:] and -[UITraitCollection traitCollectionByModifyingTraits:] to create and modify trait collections"]
67        #[unsafe(method(traitCollectionWithTraitsFromCollections:))]
68        #[unsafe(method_family = none)]
69        pub fn traitCollectionWithTraitsFromCollections(
70            trait_collections: &NSArray<UITraitCollection>,
71        ) -> Retained<UITraitCollection>;
72
73        #[cfg(feature = "UIDevice")]
74        #[unsafe(method(traitCollectionWithUserInterfaceIdiom:))]
75        #[unsafe(method_family = none)]
76        pub fn traitCollectionWithUserInterfaceIdiom(
77            idiom: UIUserInterfaceIdiom,
78        ) -> Retained<UITraitCollection>;
79
80        #[cfg(feature = "UIDevice")]
81        /// This property is not atomic.
82        ///
83        /// # Safety
84        ///
85        /// This might not be thread-safe.
86        #[unsafe(method(userInterfaceIdiom))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
89
90        #[cfg(feature = "UIInterface")]
91        #[unsafe(method(traitCollectionWithUserInterfaceStyle:))]
92        #[unsafe(method_family = none)]
93        pub fn traitCollectionWithUserInterfaceStyle(
94            user_interface_style: UIUserInterfaceStyle,
95        ) -> Retained<UITraitCollection>;
96
97        #[cfg(feature = "UIInterface")]
98        /// This property is not atomic.
99        ///
100        /// # Safety
101        ///
102        /// This might not be thread-safe.
103        #[unsafe(method(userInterfaceStyle))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
106
107        #[cfg(feature = "UIInterface")]
108        #[unsafe(method(traitCollectionWithLayoutDirection:))]
109        #[unsafe(method_family = none)]
110        pub fn traitCollectionWithLayoutDirection(
111            layout_direction: UITraitEnvironmentLayoutDirection,
112        ) -> Retained<UITraitCollection>;
113
114        #[cfg(feature = "UIInterface")]
115        /// This property is not atomic.
116        ///
117        /// # Safety
118        ///
119        /// This might not be thread-safe.
120        #[unsafe(method(layoutDirection))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
123
124        #[cfg(feature = "objc2-core-foundation")]
125        #[unsafe(method(traitCollectionWithDisplayScale:))]
126        #[unsafe(method_family = none)]
127        pub fn traitCollectionWithDisplayScale(scale: CGFloat) -> Retained<UITraitCollection>;
128
129        #[cfg(feature = "objc2-core-foundation")]
130        /// This property is not atomic.
131        ///
132        /// # Safety
133        ///
134        /// This might not be thread-safe.
135        #[unsafe(method(displayScale))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn displayScale(&self) -> CGFloat;
138
139        #[cfg(feature = "UIInterface")]
140        #[unsafe(method(traitCollectionWithHorizontalSizeClass:))]
141        #[unsafe(method_family = none)]
142        pub fn traitCollectionWithHorizontalSizeClass(
143            horizontal_size_class: UIUserInterfaceSizeClass,
144        ) -> Retained<UITraitCollection>;
145
146        #[cfg(feature = "UIInterface")]
147        /// This property is not atomic.
148        ///
149        /// # Safety
150        ///
151        /// This might not be thread-safe.
152        #[unsafe(method(horizontalSizeClass))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
155
156        #[cfg(feature = "UIInterface")]
157        #[unsafe(method(traitCollectionWithVerticalSizeClass:))]
158        #[unsafe(method_family = none)]
159        pub fn traitCollectionWithVerticalSizeClass(
160            vertical_size_class: UIUserInterfaceSizeClass,
161        ) -> Retained<UITraitCollection>;
162
163        #[cfg(feature = "UIInterface")]
164        /// This property is not atomic.
165        ///
166        /// # Safety
167        ///
168        /// This might not be thread-safe.
169        #[unsafe(method(verticalSizeClass))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
172
173        #[cfg(feature = "UITouch")]
174        #[unsafe(method(traitCollectionWithForceTouchCapability:))]
175        #[unsafe(method_family = none)]
176        pub fn traitCollectionWithForceTouchCapability(
177            capability: UIForceTouchCapability,
178        ) -> Retained<UITraitCollection>;
179
180        #[cfg(feature = "UITouch")]
181        /// This property is not atomic.
182        #[unsafe(method(forceTouchCapability))]
183        #[unsafe(method_family = none)]
184        pub fn forceTouchCapability(&self) -> UIForceTouchCapability;
185
186        #[cfg(feature = "UIContentSizeCategory")]
187        #[unsafe(method(traitCollectionWithPreferredContentSizeCategory:))]
188        #[unsafe(method_family = none)]
189        pub fn traitCollectionWithPreferredContentSizeCategory(
190            preferred_content_size_category: &UIContentSizeCategory,
191        ) -> Retained<UITraitCollection>;
192
193        #[cfg(feature = "UIContentSizeCategory")]
194        /// This property is not atomic.
195        ///
196        /// # Safety
197        ///
198        /// This might not be thread-safe.
199        #[unsafe(method(preferredContentSizeCategory))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
202
203        #[cfg(feature = "UIInterface")]
204        #[unsafe(method(traitCollectionWithDisplayGamut:))]
205        #[unsafe(method_family = none)]
206        pub fn traitCollectionWithDisplayGamut(
207            display_gamut: UIDisplayGamut,
208        ) -> Retained<UITraitCollection>;
209
210        #[cfg(feature = "UIInterface")]
211        /// This property is not atomic.
212        ///
213        /// # Safety
214        ///
215        /// This might not be thread-safe.
216        #[unsafe(method(displayGamut))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn displayGamut(&self) -> UIDisplayGamut;
219
220        #[cfg(feature = "UIInterface")]
221        #[unsafe(method(traitCollectionWithAccessibilityContrast:))]
222        #[unsafe(method_family = none)]
223        pub fn traitCollectionWithAccessibilityContrast(
224            accessibility_contrast: UIAccessibilityContrast,
225        ) -> Retained<UITraitCollection>;
226
227        #[cfg(feature = "UIInterface")]
228        /// This property is not atomic.
229        ///
230        /// # Safety
231        ///
232        /// This might not be thread-safe.
233        #[unsafe(method(accessibilityContrast))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn accessibilityContrast(&self) -> UIAccessibilityContrast;
236
237        #[cfg(feature = "UIInterface")]
238        #[unsafe(method(traitCollectionWithUserInterfaceLevel:))]
239        #[unsafe(method_family = none)]
240        pub fn traitCollectionWithUserInterfaceLevel(
241            user_interface_level: UIUserInterfaceLevel,
242        ) -> Retained<UITraitCollection>;
243
244        #[cfg(feature = "UIInterface")]
245        /// This property is not atomic.
246        ///
247        /// # Safety
248        ///
249        /// This might not be thread-safe.
250        #[unsafe(method(userInterfaceLevel))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
253
254        #[cfg(feature = "UIInterface")]
255        #[unsafe(method(traitCollectionWithLegibilityWeight:))]
256        #[unsafe(method_family = none)]
257        pub fn traitCollectionWithLegibilityWeight(
258            legibility_weight: UILegibilityWeight,
259        ) -> Retained<UITraitCollection>;
260
261        #[cfg(feature = "UIInterface")]
262        /// This property is not atomic.
263        ///
264        /// # Safety
265        ///
266        /// This might not be thread-safe.
267        #[unsafe(method(legibilityWeight))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn legibilityWeight(&self) -> UILegibilityWeight;
270
271        #[cfg(feature = "UIInterface")]
272        #[unsafe(method(traitCollectionWithActiveAppearance:))]
273        #[unsafe(method_family = none)]
274        pub fn traitCollectionWithActiveAppearance(
275            user_interface_active_appearance: UIUserInterfaceActiveAppearance,
276        ) -> Retained<UITraitCollection>;
277
278        #[cfg(feature = "UIInterface")]
279        /// This property is not atomic.
280        ///
281        /// # Safety
282        ///
283        /// This might not be thread-safe.
284        #[unsafe(method(activeAppearance))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
287
288        #[cfg(feature = "UIInterface")]
289        #[unsafe(method(traitCollectionWithToolbarItemPresentationSize:))]
290        #[unsafe(method_family = none)]
291        pub fn traitCollectionWithToolbarItemPresentationSize(
292            toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
293        ) -> Retained<UITraitCollection>;
294
295        #[cfg(feature = "UIInterface")]
296        /// This property is not atomic.
297        ///
298        /// # Safety
299        ///
300        /// This might not be thread-safe.
301        #[unsafe(method(toolbarItemPresentationSize))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
304
305        #[cfg(feature = "UIInterface")]
306        /// Construct a new trait collection with the given image content dynamic range.
307        #[unsafe(method(traitCollectionWithImageDynamicRange:))]
308        #[unsafe(method_family = none)]
309        pub fn traitCollectionWithImageDynamicRange(
310            image_dynamic_range: UIImageDynamicRange,
311        ) -> Retained<UITraitCollection>;
312
313        #[cfg(feature = "UIInterface")]
314        /// The imageDynamicRange determines how HDR images will render in the given trait environment. SDR images are unaffected.
315        ///
316        /// This property is not atomic.
317        ///
318        /// # Safety
319        ///
320        /// This might not be thread-safe.
321        #[unsafe(method(imageDynamicRange))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn imageDynamicRange(&self) -> UIImageDynamicRange;
324
325        #[unsafe(method(traitCollectionWithTypesettingLanguage:))]
326        #[unsafe(method_family = none)]
327        pub fn traitCollectionWithTypesettingLanguage(
328            language: &NSString,
329        ) -> Retained<UITraitCollection>;
330
331        /// This property is not atomic.
332        ///
333        /// # Safety
334        ///
335        /// This might not be thread-safe.
336        #[unsafe(method(typesettingLanguage))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
339
340        #[cfg(feature = "UISceneDefinitions")]
341        /// Construct a new trait collection with the given scene capture state.
342        #[unsafe(method(traitCollectionWithSceneCaptureState:))]
343        #[unsafe(method_family = none)]
344        pub fn traitCollectionWithSceneCaptureState(
345            scene_capture_state: UISceneCaptureState,
346        ) -> Retained<UITraitCollection>;
347
348        #[cfg(feature = "UISceneDefinitions")]
349        /// Scene capture state represents whether a scene is currently being mirrored or recorded.
350        ///
351        /// This property is not atomic.
352        ///
353        /// # Safety
354        ///
355        /// This might not be thread-safe.
356        #[unsafe(method(sceneCaptureState))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
359
360        #[cfg(feature = "UITraitListEnvironment")]
361        /// Construct a new trait collection with the given `listEnvironment`.
362        #[unsafe(method(traitCollectionWithListEnvironment:))]
363        #[unsafe(method_family = none)]
364        pub fn traitCollectionWithListEnvironment(
365            list_environment: UIListEnvironment,
366        ) -> Retained<UITraitCollection>;
367
368        #[cfg(feature = "UITraitListEnvironment")]
369        /// The list environment represents whether a given trait collection is from a view in a UITableView or a UICollectionView list section.
370        ///
371        /// This property is not atomic.
372        ///
373        /// # Safety
374        ///
375        /// This might not be thread-safe.
376        #[unsafe(method(listEnvironment))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn listEnvironment(&self) -> UIListEnvironment;
379
380        #[cfg(feature = "UITabAccessory")]
381        /// Constructs a new trait collection with the given `tabAccessoryEnvironment`.
382        #[unsafe(method(traitCollectionWithTabAccessoryEnvironment:))]
383        #[unsafe(method_family = none)]
384        pub fn traitCollectionWithTabAccessoryEnvironment(
385            tab_accessory_environment: UITabAccessoryEnvironment,
386        ) -> Retained<UITraitCollection>;
387
388        #[cfg(feature = "UITabAccessory")]
389        /// The tab accessory environment represents whether a given trait collection is from a view in a `UITabAccessory` content view.
390        ///
391        /// This property is not atomic.
392        ///
393        /// # Safety
394        ///
395        /// This might not be thread-safe.
396        #[unsafe(method(tabAccessoryEnvironment))]
397        #[unsafe(method_family = none)]
398        pub unsafe fn tabAccessoryEnvironment(&self) -> UITabAccessoryEnvironment;
399
400        #[cfg(feature = "UISplitViewControllerLayoutEnvironment")]
401        /// The split view controller layout environment represents whether an ancestor split view controller is expanded or collapsed.
402        ///
403        /// This property is not atomic.
404        ///
405        /// # Safety
406        ///
407        /// This might not be thread-safe.
408        #[unsafe(method(splitViewControllerLayoutEnvironment))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn splitViewControllerLayoutEnvironment(
411            &self,
412        ) -> UISplitViewControllerLayoutEnvironment;
413
414        #[cfg(feature = "UIInterface")]
415        /// If HDR headroom should be used for the current UI configuration. Headroom usage is disabled in certain UI configurations, such as when all an application's windows are in the background.
416        ///
417        /// This property is not atomic.
418        ///
419        /// # Safety
420        ///
421        /// This might not be thread-safe.
422        #[unsafe(method(hdrHeadroomUsageLimit))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn hdrHeadroomUsageLimit(&self) -> UIHDRHeadroomUsageLimit;
425
426        #[cfg(feature = "UIInterface")]
427        #[unsafe(method(traitCollectionWithHDRHeadroomUsageLimit:))]
428        #[unsafe(method_family = none)]
429        pub fn traitCollectionWithHDRHeadroomUsageLimit(
430            hdr_headroom_usage_limit: UIHDRHeadroomUsageLimit,
431        ) -> Retained<UITraitCollection>;
432
433        #[unsafe(method(traitCollectionWithResolvesNaturalAlignmentWithBaseWritingDirection:))]
434        #[unsafe(method_family = none)]
435        pub fn traitCollectionWithResolvesNaturalAlignmentWithBaseWritingDirection(
436            resolves_natural_alignment_with_base_writing_direction: bool,
437        ) -> Retained<UITraitCollection>;
438
439        /// Specifies the behavior for resolving ``NSTextAlignment.natural`` to the visual alignment.
440        ///
441        /// When set to ``true``, the resolved visual alignment is determined by the resolved base writing direction; otherwise, it is using the user’s preferred language.
442        ///
443        /// This property is not atomic.
444        ///
445        /// # Safety
446        ///
447        /// This might not be thread-safe.
448        #[unsafe(method(resolvesNaturalAlignmentWithBaseWritingDirection))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool;
451    );
452}
453
454/// Methods declared on superclass `NSObject`.
455impl UITraitCollection {
456    extern_methods!(
457        #[unsafe(method(new))]
458        #[unsafe(method_family = new)]
459        pub fn new() -> Retained<Self>;
460    );
461}
462
463impl DefaultRetained for UITraitCollection {
464    #[inline]
465    fn default_retained() -> Retained<Self> {
466        Self::new()
467    }
468}
469
470extern_protocol!(
471    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimutabletraits?language=objc)
472    pub unsafe trait UIMutableTraits: NSObjectProtocol + MainThreadOnly {
473        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
474        /// # Safety
475        ///
476        /// `trait` must implement UICGFloatTraitDefinition.
477        #[unsafe(method(setCGFloatValue:forTrait:))]
478        #[unsafe(method_family = none)]
479        unsafe fn setCGFloatValue_forTrait(&self, value: CGFloat, r#trait: &UICGFloatTrait);
480
481        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
482        /// # Safety
483        ///
484        /// `trait` must implement UICGFloatTraitDefinition.
485        #[unsafe(method(valueForCGFloatTrait:))]
486        #[unsafe(method_family = none)]
487        unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
488
489        #[cfg(feature = "UITrait")]
490        /// # Safety
491        ///
492        /// `trait` must implement UINSIntegerTraitDefinition.
493        #[unsafe(method(setNSIntegerValue:forTrait:))]
494        #[unsafe(method_family = none)]
495        unsafe fn setNSIntegerValue_forTrait(&self, value: NSInteger, r#trait: &UINSIntegerTrait);
496
497        #[cfg(feature = "UITrait")]
498        /// # Safety
499        ///
500        /// `trait` must implement UINSIntegerTraitDefinition.
501        #[unsafe(method(valueForNSIntegerTrait:))]
502        #[unsafe(method_family = none)]
503        unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
504
505        #[cfg(feature = "UITrait")]
506        /// # Safety
507        ///
508        /// - `object` should be of the correct type.
509        /// - `trait` must implement UIObjectTraitDefinition.
510        #[unsafe(method(setObject:forTrait:))]
511        #[unsafe(method_family = none)]
512        unsafe fn setObject_forTrait(
513            &self,
514            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
515            r#trait: &UIObjectTrait,
516        );
517
518        #[cfg(feature = "UITrait")]
519        /// # Safety
520        ///
521        /// `trait` must implement UIObjectTraitDefinition.
522        #[unsafe(method(objectForTrait:))]
523        #[unsafe(method_family = none)]
524        unsafe fn objectForTrait(
525            &self,
526            r#trait: &UIObjectTrait,
527        ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
528
529        #[cfg(feature = "UIDevice")]
530        #[unsafe(method(userInterfaceIdiom))]
531        #[unsafe(method_family = none)]
532        fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
533
534        #[cfg(feature = "UIDevice")]
535        /// Setter for [`userInterfaceIdiom`][Self::userInterfaceIdiom].
536        #[unsafe(method(setUserInterfaceIdiom:))]
537        #[unsafe(method_family = none)]
538        fn setUserInterfaceIdiom(&self, user_interface_idiom: UIUserInterfaceIdiom);
539
540        #[cfg(feature = "UIInterface")]
541        #[unsafe(method(userInterfaceStyle))]
542        #[unsafe(method_family = none)]
543        fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
544
545        #[cfg(feature = "UIInterface")]
546        /// Setter for [`userInterfaceStyle`][Self::userInterfaceStyle].
547        #[unsafe(method(setUserInterfaceStyle:))]
548        #[unsafe(method_family = none)]
549        fn setUserInterfaceStyle(&self, user_interface_style: UIUserInterfaceStyle);
550
551        #[cfg(feature = "UIInterface")]
552        #[unsafe(method(layoutDirection))]
553        #[unsafe(method_family = none)]
554        fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
555
556        #[cfg(feature = "UIInterface")]
557        /// Setter for [`layoutDirection`][Self::layoutDirection].
558        #[unsafe(method(setLayoutDirection:))]
559        #[unsafe(method_family = none)]
560        fn setLayoutDirection(&self, layout_direction: UITraitEnvironmentLayoutDirection);
561
562        #[cfg(feature = "objc2-core-foundation")]
563        #[unsafe(method(displayScale))]
564        #[unsafe(method_family = none)]
565        fn displayScale(&self) -> CGFloat;
566
567        #[cfg(feature = "objc2-core-foundation")]
568        /// Setter for [`displayScale`][Self::displayScale].
569        #[unsafe(method(setDisplayScale:))]
570        #[unsafe(method_family = none)]
571        fn setDisplayScale(&self, display_scale: CGFloat);
572
573        #[cfg(feature = "UIInterface")]
574        #[unsafe(method(horizontalSizeClass))]
575        #[unsafe(method_family = none)]
576        fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
577
578        #[cfg(feature = "UIInterface")]
579        /// Setter for [`horizontalSizeClass`][Self::horizontalSizeClass].
580        #[unsafe(method(setHorizontalSizeClass:))]
581        #[unsafe(method_family = none)]
582        fn setHorizontalSizeClass(&self, horizontal_size_class: UIUserInterfaceSizeClass);
583
584        #[cfg(feature = "UIInterface")]
585        #[unsafe(method(verticalSizeClass))]
586        #[unsafe(method_family = none)]
587        fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
588
589        #[cfg(feature = "UIInterface")]
590        /// Setter for [`verticalSizeClass`][Self::verticalSizeClass].
591        #[unsafe(method(setVerticalSizeClass:))]
592        #[unsafe(method_family = none)]
593        fn setVerticalSizeClass(&self, vertical_size_class: UIUserInterfaceSizeClass);
594
595        #[cfg(feature = "UITouch")]
596        #[unsafe(method(forceTouchCapability))]
597        #[unsafe(method_family = none)]
598        fn forceTouchCapability(&self) -> UIForceTouchCapability;
599
600        #[cfg(feature = "UITouch")]
601        /// Setter for [`forceTouchCapability`][Self::forceTouchCapability].
602        #[unsafe(method(setForceTouchCapability:))]
603        #[unsafe(method_family = none)]
604        fn setForceTouchCapability(&self, force_touch_capability: UIForceTouchCapability);
605
606        #[cfg(feature = "UIContentSizeCategory")]
607        #[unsafe(method(preferredContentSizeCategory))]
608        #[unsafe(method_family = none)]
609        fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
610
611        #[cfg(feature = "UIContentSizeCategory")]
612        /// Setter for [`preferredContentSizeCategory`][Self::preferredContentSizeCategory].
613        ///
614        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
615        #[unsafe(method(setPreferredContentSizeCategory:))]
616        #[unsafe(method_family = none)]
617        fn setPreferredContentSizeCategory(
618            &self,
619            preferred_content_size_category: &UIContentSizeCategory,
620        );
621
622        #[cfg(feature = "UIInterface")]
623        #[unsafe(method(displayGamut))]
624        #[unsafe(method_family = none)]
625        fn displayGamut(&self) -> UIDisplayGamut;
626
627        #[cfg(feature = "UIInterface")]
628        /// Setter for [`displayGamut`][Self::displayGamut].
629        #[unsafe(method(setDisplayGamut:))]
630        #[unsafe(method_family = none)]
631        fn setDisplayGamut(&self, display_gamut: UIDisplayGamut);
632
633        #[cfg(feature = "UIInterface")]
634        #[unsafe(method(accessibilityContrast))]
635        #[unsafe(method_family = none)]
636        fn accessibilityContrast(&self) -> UIAccessibilityContrast;
637
638        #[cfg(feature = "UIInterface")]
639        /// Setter for [`accessibilityContrast`][Self::accessibilityContrast].
640        #[unsafe(method(setAccessibilityContrast:))]
641        #[unsafe(method_family = none)]
642        fn setAccessibilityContrast(&self, accessibility_contrast: UIAccessibilityContrast);
643
644        #[cfg(feature = "UIInterface")]
645        #[unsafe(method(userInterfaceLevel))]
646        #[unsafe(method_family = none)]
647        fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
648
649        #[cfg(feature = "UIInterface")]
650        /// Setter for [`userInterfaceLevel`][Self::userInterfaceLevel].
651        #[unsafe(method(setUserInterfaceLevel:))]
652        #[unsafe(method_family = none)]
653        fn setUserInterfaceLevel(&self, user_interface_level: UIUserInterfaceLevel);
654
655        #[cfg(feature = "UIInterface")]
656        #[unsafe(method(legibilityWeight))]
657        #[unsafe(method_family = none)]
658        fn legibilityWeight(&self) -> UILegibilityWeight;
659
660        #[cfg(feature = "UIInterface")]
661        /// Setter for [`legibilityWeight`][Self::legibilityWeight].
662        #[unsafe(method(setLegibilityWeight:))]
663        #[unsafe(method_family = none)]
664        fn setLegibilityWeight(&self, legibility_weight: UILegibilityWeight);
665
666        #[cfg(feature = "UIInterface")]
667        #[unsafe(method(activeAppearance))]
668        #[unsafe(method_family = none)]
669        fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
670
671        #[cfg(feature = "UIInterface")]
672        /// Setter for [`activeAppearance`][Self::activeAppearance].
673        #[unsafe(method(setActiveAppearance:))]
674        #[unsafe(method_family = none)]
675        fn setActiveAppearance(&self, active_appearance: UIUserInterfaceActiveAppearance);
676
677        #[cfg(feature = "UIInterface")]
678        #[unsafe(method(toolbarItemPresentationSize))]
679        #[unsafe(method_family = none)]
680        fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
681
682        #[cfg(feature = "UIInterface")]
683        /// Setter for [`toolbarItemPresentationSize`][Self::toolbarItemPresentationSize].
684        #[unsafe(method(setToolbarItemPresentationSize:))]
685        #[unsafe(method_family = none)]
686        fn setToolbarItemPresentationSize(
687            &self,
688            toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
689        );
690
691        #[cfg(feature = "UIInterface")]
692        #[unsafe(method(imageDynamicRange))]
693        #[unsafe(method_family = none)]
694        fn imageDynamicRange(&self) -> UIImageDynamicRange;
695
696        #[cfg(feature = "UIInterface")]
697        /// Setter for [`imageDynamicRange`][Self::imageDynamicRange].
698        #[unsafe(method(setImageDynamicRange:))]
699        #[unsafe(method_family = none)]
700        fn setImageDynamicRange(&self, image_dynamic_range: UIImageDynamicRange);
701
702        #[cfg(feature = "UISceneDefinitions")]
703        #[unsafe(method(sceneCaptureState))]
704        #[unsafe(method_family = none)]
705        fn sceneCaptureState(&self) -> UISceneCaptureState;
706
707        #[cfg(feature = "UISceneDefinitions")]
708        /// Setter for [`sceneCaptureState`][Self::sceneCaptureState].
709        #[unsafe(method(setSceneCaptureState:))]
710        #[unsafe(method_family = none)]
711        fn setSceneCaptureState(&self, scene_capture_state: UISceneCaptureState);
712
713        #[unsafe(method(typesettingLanguage))]
714        #[unsafe(method_family = none)]
715        fn typesettingLanguage(&self) -> Retained<NSString>;
716
717        /// Setter for [`typesettingLanguage`][Self::typesettingLanguage].
718        ///
719        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
720        #[unsafe(method(setTypesettingLanguage:))]
721        #[unsafe(method_family = none)]
722        fn setTypesettingLanguage(&self, typesetting_language: &NSString);
723
724        #[cfg(feature = "UITraitListEnvironment")]
725        #[unsafe(method(listEnvironment))]
726        #[unsafe(method_family = none)]
727        fn listEnvironment(&self) -> UIListEnvironment;
728
729        #[cfg(feature = "UITraitListEnvironment")]
730        /// Setter for [`listEnvironment`][Self::listEnvironment].
731        #[unsafe(method(setListEnvironment:))]
732        #[unsafe(method_family = none)]
733        fn setListEnvironment(&self, list_environment: UIListEnvironment);
734
735        #[cfg(feature = "UITabAccessory")]
736        #[unsafe(method(tabAccessoryEnvironment))]
737        #[unsafe(method_family = none)]
738        fn tabAccessoryEnvironment(&self) -> UITabAccessoryEnvironment;
739
740        #[cfg(feature = "UITabAccessory")]
741        /// Setter for [`tabAccessoryEnvironment`][Self::tabAccessoryEnvironment].
742        #[unsafe(method(setTabAccessoryEnvironment:))]
743        #[unsafe(method_family = none)]
744        fn setTabAccessoryEnvironment(&self, tab_accessory_environment: UITabAccessoryEnvironment);
745
746        #[cfg(feature = "UISplitViewControllerLayoutEnvironment")]
747        #[unsafe(method(splitViewControllerLayoutEnvironment))]
748        #[unsafe(method_family = none)]
749        fn splitViewControllerLayoutEnvironment(&self) -> UISplitViewControllerLayoutEnvironment;
750
751        #[cfg(feature = "UISplitViewControllerLayoutEnvironment")]
752        /// Setter for [`splitViewControllerLayoutEnvironment`][Self::splitViewControllerLayoutEnvironment].
753        #[unsafe(method(setSplitViewControllerLayoutEnvironment:))]
754        #[unsafe(method_family = none)]
755        fn setSplitViewControllerLayoutEnvironment(
756            &self,
757            split_view_controller_layout_environment: UISplitViewControllerLayoutEnvironment,
758        );
759
760        #[unsafe(method(resolvesNaturalAlignmentWithBaseWritingDirection))]
761        #[unsafe(method_family = none)]
762        fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool;
763
764        /// Setter for [`resolvesNaturalAlignmentWithBaseWritingDirection`][Self::resolvesNaturalAlignmentWithBaseWritingDirection].
765        #[unsafe(method(setResolvesNaturalAlignmentWithBaseWritingDirection:))]
766        #[unsafe(method_family = none)]
767        fn setResolvesNaturalAlignmentWithBaseWritingDirection(
768            &self,
769            resolves_natural_alignment_with_base_writing_direction: bool,
770        );
771    }
772);
773
774/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitmutations?language=objc)
775#[cfg(feature = "block2")]
776pub type UITraitMutations =
777    *mut block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn UIMutableTraits>>)>;
778
779impl UITraitCollection {
780    extern_methods!(
781        #[cfg(feature = "block2")]
782        /// # Safety
783        ///
784        /// `mutations` must be a valid pointer.
785        #[unsafe(method(traitCollectionWithTraits:))]
786        #[unsafe(method_family = none)]
787        pub unsafe fn traitCollectionWithTraits(
788            mutations: UITraitMutations,
789        ) -> Retained<UITraitCollection>;
790
791        #[cfg(feature = "block2")]
792        /// # Safety
793        ///
794        /// `mutations` must be a valid pointer.
795        #[unsafe(method(traitCollectionByModifyingTraits:))]
796        #[unsafe(method_family = none)]
797        pub unsafe fn traitCollectionByModifyingTraits(
798            &self,
799            mutations: UITraitMutations,
800        ) -> Retained<UITraitCollection>;
801
802        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
803        /// # Safety
804        ///
805        /// `trait` must implement UICGFloatTraitDefinition.
806        #[unsafe(method(traitCollectionWithCGFloatValue:forTrait:))]
807        #[unsafe(method_family = none)]
808        pub unsafe fn traitCollectionWithCGFloatValue_forTrait(
809            value: CGFloat,
810            r#trait: &UICGFloatTrait,
811        ) -> Retained<UITraitCollection>;
812
813        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
814        /// # Safety
815        ///
816        /// `trait` must implement UICGFloatTraitDefinition.
817        #[unsafe(method(traitCollectionByReplacingCGFloatValue:forTrait:))]
818        #[unsafe(method_family = none)]
819        pub unsafe fn traitCollectionByReplacingCGFloatValue_forTrait(
820            &self,
821            value: CGFloat,
822            r#trait: &UICGFloatTrait,
823        ) -> Retained<UITraitCollection>;
824
825        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
826        /// # Safety
827        ///
828        /// `trait` must implement UICGFloatTraitDefinition.
829        #[unsafe(method(valueForCGFloatTrait:))]
830        #[unsafe(method_family = none)]
831        pub unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
832
833        #[cfg(feature = "UITrait")]
834        /// # Safety
835        ///
836        /// `trait` must implement UINSIntegerTraitDefinition.
837        #[unsafe(method(traitCollectionWithNSIntegerValue:forTrait:))]
838        #[unsafe(method_family = none)]
839        pub unsafe fn traitCollectionWithNSIntegerValue_forTrait(
840            value: NSInteger,
841            r#trait: &UINSIntegerTrait,
842        ) -> Retained<UITraitCollection>;
843
844        #[cfg(feature = "UITrait")]
845        /// # Safety
846        ///
847        /// `trait` must implement UINSIntegerTraitDefinition.
848        #[unsafe(method(traitCollectionByReplacingNSIntegerValue:forTrait:))]
849        #[unsafe(method_family = none)]
850        pub unsafe fn traitCollectionByReplacingNSIntegerValue_forTrait(
851            &self,
852            value: NSInteger,
853            r#trait: &UINSIntegerTrait,
854        ) -> Retained<UITraitCollection>;
855
856        #[cfg(feature = "UITrait")]
857        /// # Safety
858        ///
859        /// `trait` must implement UINSIntegerTraitDefinition.
860        #[unsafe(method(valueForNSIntegerTrait:))]
861        #[unsafe(method_family = none)]
862        pub unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
863
864        #[cfg(feature = "UITrait")]
865        /// # Safety
866        ///
867        /// - `object` should be of the correct type.
868        /// - `trait` must implement UIObjectTraitDefinition.
869        #[unsafe(method(traitCollectionWithObject:forTrait:))]
870        #[unsafe(method_family = none)]
871        pub unsafe fn traitCollectionWithObject_forTrait(
872            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
873            r#trait: &UIObjectTrait,
874        ) -> Retained<UITraitCollection>;
875
876        #[cfg(feature = "UITrait")]
877        /// # Safety
878        ///
879        /// - `object` should be of the correct type.
880        /// - `trait` must implement UIObjectTraitDefinition.
881        #[unsafe(method(traitCollectionByReplacingObject:forTrait:))]
882        #[unsafe(method_family = none)]
883        pub unsafe fn traitCollectionByReplacingObject_forTrait(
884            &self,
885            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
886            r#trait: &UIObjectTrait,
887        ) -> Retained<UITraitCollection>;
888
889        #[cfg(feature = "UITrait")]
890        /// # Safety
891        ///
892        /// `trait` must implement UIObjectTraitDefinition.
893        #[unsafe(method(objectForTrait:))]
894        #[unsafe(method_family = none)]
895        pub unsafe fn objectForTrait(
896            &self,
897            r#trait: &UIObjectTrait,
898        ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
899    );
900}
901
902extern_protocol!(
903    /// Trait environments expose a trait collection that describes their environment.
904    ///
905    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitenvironment?language=objc)
906    pub unsafe trait UITraitEnvironment: NSObjectProtocol + MainThreadOnly {
907        #[unsafe(method(traitCollection))]
908        #[unsafe(method_family = none)]
909        fn traitCollection(&self) -> Retained<UITraitCollection>;
910
911        /// To be overridden as needed to provide custom behavior when the environment's traits change.
912        #[deprecated = "Use the trait change registration APIs declared in the UITraitChangeObservable protocol"]
913        #[unsafe(method(traitCollectionDidChange:))]
914        #[unsafe(method_family = none)]
915        fn traitCollectionDidChange(&self, previous_trait_collection: Option<&UITraitCollection>);
916    }
917);
918
919extern_protocol!(
920    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangeregistration?language=objc)
921    pub unsafe trait UITraitChangeRegistration:
922        NSObjectProtocol + NSCopying + MainThreadOnly
923    {
924    }
925);
926
927/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangehandler?language=objc)
928#[cfg(feature = "block2")]
929pub type UITraitChangeHandler = *mut block2::DynBlock<
930    dyn Fn(NonNull<ProtocolObject<dyn UITraitEnvironment>>, NonNull<UITraitCollection>),
931>;
932
933extern_protocol!(
934    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitoverrides?language=objc)
935    pub unsafe trait UITraitOverrides: UIMutableTraits + MainThreadOnly {
936        #[cfg(feature = "UITrait")]
937        /// # Safety
938        ///
939        /// `trait` must implement UITraitDefinition.
940        #[unsafe(method(containsTrait:))]
941        #[unsafe(method_family = none)]
942        unsafe fn containsTrait(&self, r#trait: &UITrait) -> bool;
943
944        #[cfg(feature = "UITrait")]
945        /// # Safety
946        ///
947        /// `trait` must implement UITraitDefinition.
948        #[unsafe(method(removeTrait:))]
949        #[unsafe(method_family = none)]
950        unsafe fn removeTrait(&self, r#trait: &UITrait);
951    }
952);
953
954extern_protocol!(
955    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangeobservable?language=objc)
956    pub unsafe trait UITraitChangeObservable: MainThreadOnly {
957        #[unsafe(method(unregisterForTraitChanges:))]
958        #[unsafe(method_family = none)]
959        fn unregisterForTraitChanges(
960            &self,
961            registration: &ProtocolObject<dyn UITraitChangeRegistration>,
962        );
963    }
964);
965
966/// CurrentTraitCollection.
967impl UITraitCollection {
968    extern_methods!(
969        /// This property is not atomic.
970        ///
971        /// # Safety
972        ///
973        /// This might not be thread-safe.
974        #[unsafe(method(currentTraitCollection))]
975        #[unsafe(method_family = none)]
976        pub unsafe fn currentTraitCollection() -> Retained<UITraitCollection>;
977
978        /// Setter for [`currentTraitCollection`][Self::currentTraitCollection].
979        ///
980        /// # Safety
981        ///
982        /// This might not be thread-safe.
983        #[unsafe(method(setCurrentTraitCollection:))]
984        #[unsafe(method_family = none)]
985        pub unsafe fn setCurrentTraitCollection(current_trait_collection: &UITraitCollection);
986
987        #[cfg(feature = "block2")]
988        #[unsafe(method(performAsCurrentTraitCollection:))]
989        #[unsafe(method_family = none)]
990        pub fn performAsCurrentTraitCollection(&self, actions: &block2::DynBlock<dyn Fn() + '_>);
991    );
992}
993
994/// DynamicAppearance.
995impl UITraitCollection {
996    extern_methods!(
997        #[unsafe(method(hasDifferentColorAppearanceComparedToTraitCollection:))]
998        #[unsafe(method_family = none)]
999        pub fn hasDifferentColorAppearanceComparedToTraitCollection(
1000            &self,
1001            trait_collection: Option<&UITraitCollection>,
1002        ) -> bool;
1003    );
1004}
1005
1006/// ImageConfiguration.
1007impl UITraitCollection {
1008    extern_methods!(
1009        #[cfg(feature = "UIImageConfiguration")]
1010        /// This property is not atomic.
1011        ///
1012        /// # Safety
1013        ///
1014        /// This might not be thread-safe.
1015        #[unsafe(method(imageConfiguration))]
1016        #[unsafe(method_family = none)]
1017        pub unsafe fn imageConfiguration(&self) -> Retained<UIImageConfiguration>;
1018    );
1019}