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
25unsafe impl NSCoding for UITraitCollection {}
26
27unsafe impl NSCopying for UITraitCollection {}
28
29unsafe impl CopyingHelper for UITraitCollection {
30    type Result = Self;
31}
32
33unsafe impl NSObjectProtocol for UITraitCollection {}
34
35unsafe impl NSSecureCoding for UITraitCollection {}
36
37impl UITraitCollection {
38    extern_methods!(
39        #[unsafe(method(init))]
40        #[unsafe(method_family = init)]
41        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
42
43        #[unsafe(method(initWithCoder:))]
44        #[unsafe(method_family = init)]
45        pub unsafe fn initWithCoder(
46            this: Allocated<Self>,
47            coder: &NSCoder,
48        ) -> Option<Retained<Self>>;
49
50        #[deprecated = "Compare values for specific traits in the trait collections instead"]
51        #[unsafe(method(containsTraitsInCollection:))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn containsTraitsInCollection(
54            &self,
55            r#trait: Option<&UITraitCollection>,
56        ) -> bool;
57
58        #[deprecated = "Use +[UITraitCollection traitCollectionWithTraits:] and -[UITraitCollection traitCollectionByModifyingTraits:] to create and modify trait collections"]
59        #[unsafe(method(traitCollectionWithTraitsFromCollections:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn traitCollectionWithTraitsFromCollections(
62            trait_collections: &NSArray<UITraitCollection>,
63        ) -> Retained<UITraitCollection>;
64
65        #[cfg(feature = "UIDevice")]
66        #[unsafe(method(traitCollectionWithUserInterfaceIdiom:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn traitCollectionWithUserInterfaceIdiom(
69            idiom: UIUserInterfaceIdiom,
70        ) -> Retained<UITraitCollection>;
71
72        #[cfg(feature = "UIDevice")]
73        #[unsafe(method(userInterfaceIdiom))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
76
77        #[cfg(feature = "UIInterface")]
78        #[unsafe(method(traitCollectionWithUserInterfaceStyle:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn traitCollectionWithUserInterfaceStyle(
81            user_interface_style: UIUserInterfaceStyle,
82        ) -> Retained<UITraitCollection>;
83
84        #[cfg(feature = "UIInterface")]
85        #[unsafe(method(userInterfaceStyle))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
88
89        #[cfg(feature = "UIInterface")]
90        #[unsafe(method(traitCollectionWithLayoutDirection:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn traitCollectionWithLayoutDirection(
93            layout_direction: UITraitEnvironmentLayoutDirection,
94        ) -> Retained<UITraitCollection>;
95
96        #[cfg(feature = "UIInterface")]
97        #[unsafe(method(layoutDirection))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
100
101        #[cfg(feature = "objc2-core-foundation")]
102        #[unsafe(method(traitCollectionWithDisplayScale:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn traitCollectionWithDisplayScale(
105            scale: CGFloat,
106        ) -> Retained<UITraitCollection>;
107
108        #[cfg(feature = "objc2-core-foundation")]
109        #[unsafe(method(displayScale))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn displayScale(&self) -> CGFloat;
112
113        #[cfg(feature = "UIInterface")]
114        #[unsafe(method(traitCollectionWithHorizontalSizeClass:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn traitCollectionWithHorizontalSizeClass(
117            horizontal_size_class: UIUserInterfaceSizeClass,
118        ) -> Retained<UITraitCollection>;
119
120        #[cfg(feature = "UIInterface")]
121        #[unsafe(method(horizontalSizeClass))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
124
125        #[cfg(feature = "UIInterface")]
126        #[unsafe(method(traitCollectionWithVerticalSizeClass:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn traitCollectionWithVerticalSizeClass(
129            vertical_size_class: UIUserInterfaceSizeClass,
130        ) -> Retained<UITraitCollection>;
131
132        #[cfg(feature = "UIInterface")]
133        #[unsafe(method(verticalSizeClass))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
136
137        #[cfg(feature = "UITouch")]
138        #[unsafe(method(traitCollectionWithForceTouchCapability:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn traitCollectionWithForceTouchCapability(
141            capability: UIForceTouchCapability,
142        ) -> Retained<UITraitCollection>;
143
144        #[cfg(feature = "UITouch")]
145        #[unsafe(method(forceTouchCapability))]
146        #[unsafe(method_family = none)]
147        pub fn forceTouchCapability(&self) -> UIForceTouchCapability;
148
149        #[cfg(feature = "UIContentSizeCategory")]
150        #[unsafe(method(traitCollectionWithPreferredContentSizeCategory:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn traitCollectionWithPreferredContentSizeCategory(
153            preferred_content_size_category: &UIContentSizeCategory,
154        ) -> Retained<UITraitCollection>;
155
156        #[cfg(feature = "UIContentSizeCategory")]
157        #[unsafe(method(preferredContentSizeCategory))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
160
161        #[cfg(feature = "UIInterface")]
162        #[unsafe(method(traitCollectionWithDisplayGamut:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn traitCollectionWithDisplayGamut(
165            display_gamut: UIDisplayGamut,
166        ) -> Retained<UITraitCollection>;
167
168        #[cfg(feature = "UIInterface")]
169        #[unsafe(method(displayGamut))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn displayGamut(&self) -> UIDisplayGamut;
172
173        #[cfg(feature = "UIInterface")]
174        #[unsafe(method(traitCollectionWithAccessibilityContrast:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn traitCollectionWithAccessibilityContrast(
177            accessibility_contrast: UIAccessibilityContrast,
178        ) -> Retained<UITraitCollection>;
179
180        #[cfg(feature = "UIInterface")]
181        #[unsafe(method(accessibilityContrast))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn accessibilityContrast(&self) -> UIAccessibilityContrast;
184
185        #[cfg(feature = "UIInterface")]
186        #[unsafe(method(traitCollectionWithUserInterfaceLevel:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn traitCollectionWithUserInterfaceLevel(
189            user_interface_level: UIUserInterfaceLevel,
190        ) -> Retained<UITraitCollection>;
191
192        #[cfg(feature = "UIInterface")]
193        #[unsafe(method(userInterfaceLevel))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
196
197        #[cfg(feature = "UIInterface")]
198        #[unsafe(method(traitCollectionWithLegibilityWeight:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn traitCollectionWithLegibilityWeight(
201            legibility_weight: UILegibilityWeight,
202        ) -> Retained<UITraitCollection>;
203
204        #[cfg(feature = "UIInterface")]
205        #[unsafe(method(legibilityWeight))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn legibilityWeight(&self) -> UILegibilityWeight;
208
209        #[cfg(feature = "UIInterface")]
210        #[unsafe(method(traitCollectionWithActiveAppearance:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn traitCollectionWithActiveAppearance(
213            user_interface_active_appearance: UIUserInterfaceActiveAppearance,
214        ) -> Retained<UITraitCollection>;
215
216        #[cfg(feature = "UIInterface")]
217        #[unsafe(method(activeAppearance))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
220
221        #[cfg(feature = "UIInterface")]
222        #[unsafe(method(traitCollectionWithToolbarItemPresentationSize:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn traitCollectionWithToolbarItemPresentationSize(
225            toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
226        ) -> Retained<UITraitCollection>;
227
228        #[cfg(feature = "UIInterface")]
229        #[unsafe(method(toolbarItemPresentationSize))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
232
233        #[cfg(feature = "UIInterface")]
234        /// Construct a new trait collection with the given image content dynamic range.
235        #[unsafe(method(traitCollectionWithImageDynamicRange:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn traitCollectionWithImageDynamicRange(
238            image_dynamic_range: UIImageDynamicRange,
239        ) -> Retained<UITraitCollection>;
240
241        #[cfg(feature = "UIInterface")]
242        /// The imageDynamicRange determines how HDR images will render in the given trait environment. SDR images are unaffected.
243        #[unsafe(method(imageDynamicRange))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn imageDynamicRange(&self) -> UIImageDynamicRange;
246
247        #[unsafe(method(traitCollectionWithTypesettingLanguage:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn traitCollectionWithTypesettingLanguage(
250            language: &NSString,
251        ) -> Retained<UITraitCollection>;
252
253        #[unsafe(method(typesettingLanguage))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
256
257        #[cfg(feature = "UISceneDefinitions")]
258        /// Construct a new trait collection with the given scene capture state.
259        #[unsafe(method(traitCollectionWithSceneCaptureState:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn traitCollectionWithSceneCaptureState(
262            scene_capture_state: UISceneCaptureState,
263        ) -> Retained<UITraitCollection>;
264
265        #[cfg(feature = "UISceneDefinitions")]
266        /// Scene capture state represents whether a scene is currently being mirrored or recorded.
267        #[unsafe(method(sceneCaptureState))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
270
271        #[cfg(feature = "UITraitListEnvironment")]
272        /// Construct a new trait collection with the given `listEnvironment`.
273        #[unsafe(method(traitCollectionWithListEnvironment:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn traitCollectionWithListEnvironment(
276            list_environment: UIListEnvironment,
277        ) -> Retained<UITraitCollection>;
278
279        #[cfg(feature = "UITraitListEnvironment")]
280        /// The list environment represents whether a given trait collection is from a view in a UITableView or a UICollectionView list section.
281        #[unsafe(method(listEnvironment))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn listEnvironment(&self) -> UIListEnvironment;
284    );
285}
286
287/// Methods declared on superclass `NSObject`.
288impl UITraitCollection {
289    extern_methods!(
290        #[unsafe(method(new))]
291        #[unsafe(method_family = new)]
292        pub unsafe fn new() -> Retained<Self>;
293    );
294}
295
296extern_protocol!(
297    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimutabletraits?language=objc)
298    pub unsafe trait UIMutableTraits: NSObjectProtocol + MainThreadOnly {
299        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
300        #[unsafe(method(setCGFloatValue:forTrait:))]
301        #[unsafe(method_family = none)]
302        unsafe fn setCGFloatValue_forTrait(&self, value: CGFloat, r#trait: &UICGFloatTrait);
303
304        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
305        #[unsafe(method(valueForCGFloatTrait:))]
306        #[unsafe(method_family = none)]
307        unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
308
309        #[cfg(feature = "UITrait")]
310        #[unsafe(method(setNSIntegerValue:forTrait:))]
311        #[unsafe(method_family = none)]
312        unsafe fn setNSIntegerValue_forTrait(&self, value: NSInteger, r#trait: &UINSIntegerTrait);
313
314        #[cfg(feature = "UITrait")]
315        #[unsafe(method(valueForNSIntegerTrait:))]
316        #[unsafe(method_family = none)]
317        unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
318
319        #[cfg(feature = "UITrait")]
320        #[unsafe(method(setObject:forTrait:))]
321        #[unsafe(method_family = none)]
322        unsafe fn setObject_forTrait(
323            &self,
324            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
325            r#trait: &UIObjectTrait,
326        );
327
328        #[cfg(feature = "UITrait")]
329        #[unsafe(method(objectForTrait:))]
330        #[unsafe(method_family = none)]
331        unsafe fn objectForTrait(
332            &self,
333            r#trait: &UIObjectTrait,
334        ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
335
336        #[cfg(feature = "UIDevice")]
337        #[unsafe(method(userInterfaceIdiom))]
338        #[unsafe(method_family = none)]
339        unsafe fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
340
341        #[cfg(feature = "UIDevice")]
342        /// Setter for [`userInterfaceIdiom`][Self::userInterfaceIdiom].
343        #[unsafe(method(setUserInterfaceIdiom:))]
344        #[unsafe(method_family = none)]
345        unsafe fn setUserInterfaceIdiom(&self, user_interface_idiom: UIUserInterfaceIdiom);
346
347        #[cfg(feature = "UIInterface")]
348        #[unsafe(method(userInterfaceStyle))]
349        #[unsafe(method_family = none)]
350        unsafe fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
351
352        #[cfg(feature = "UIInterface")]
353        /// Setter for [`userInterfaceStyle`][Self::userInterfaceStyle].
354        #[unsafe(method(setUserInterfaceStyle:))]
355        #[unsafe(method_family = none)]
356        unsafe fn setUserInterfaceStyle(&self, user_interface_style: UIUserInterfaceStyle);
357
358        #[cfg(feature = "UIInterface")]
359        #[unsafe(method(layoutDirection))]
360        #[unsafe(method_family = none)]
361        unsafe fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
362
363        #[cfg(feature = "UIInterface")]
364        /// Setter for [`layoutDirection`][Self::layoutDirection].
365        #[unsafe(method(setLayoutDirection:))]
366        #[unsafe(method_family = none)]
367        unsafe fn setLayoutDirection(&self, layout_direction: UITraitEnvironmentLayoutDirection);
368
369        #[cfg(feature = "objc2-core-foundation")]
370        #[unsafe(method(displayScale))]
371        #[unsafe(method_family = none)]
372        unsafe fn displayScale(&self) -> CGFloat;
373
374        #[cfg(feature = "objc2-core-foundation")]
375        /// Setter for [`displayScale`][Self::displayScale].
376        #[unsafe(method(setDisplayScale:))]
377        #[unsafe(method_family = none)]
378        unsafe fn setDisplayScale(&self, display_scale: CGFloat);
379
380        #[cfg(feature = "UIInterface")]
381        #[unsafe(method(horizontalSizeClass))]
382        #[unsafe(method_family = none)]
383        unsafe fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
384
385        #[cfg(feature = "UIInterface")]
386        /// Setter for [`horizontalSizeClass`][Self::horizontalSizeClass].
387        #[unsafe(method(setHorizontalSizeClass:))]
388        #[unsafe(method_family = none)]
389        unsafe fn setHorizontalSizeClass(&self, horizontal_size_class: UIUserInterfaceSizeClass);
390
391        #[cfg(feature = "UIInterface")]
392        #[unsafe(method(verticalSizeClass))]
393        #[unsafe(method_family = none)]
394        unsafe fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
395
396        #[cfg(feature = "UIInterface")]
397        /// Setter for [`verticalSizeClass`][Self::verticalSizeClass].
398        #[unsafe(method(setVerticalSizeClass:))]
399        #[unsafe(method_family = none)]
400        unsafe fn setVerticalSizeClass(&self, vertical_size_class: UIUserInterfaceSizeClass);
401
402        #[cfg(feature = "UITouch")]
403        #[unsafe(method(forceTouchCapability))]
404        #[unsafe(method_family = none)]
405        unsafe fn forceTouchCapability(&self) -> UIForceTouchCapability;
406
407        #[cfg(feature = "UITouch")]
408        /// Setter for [`forceTouchCapability`][Self::forceTouchCapability].
409        #[unsafe(method(setForceTouchCapability:))]
410        #[unsafe(method_family = none)]
411        unsafe fn setForceTouchCapability(&self, force_touch_capability: UIForceTouchCapability);
412
413        #[cfg(feature = "UIContentSizeCategory")]
414        #[unsafe(method(preferredContentSizeCategory))]
415        #[unsafe(method_family = none)]
416        unsafe fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
417
418        #[cfg(feature = "UIContentSizeCategory")]
419        /// Setter for [`preferredContentSizeCategory`][Self::preferredContentSizeCategory].
420        #[unsafe(method(setPreferredContentSizeCategory:))]
421        #[unsafe(method_family = none)]
422        unsafe fn setPreferredContentSizeCategory(
423            &self,
424            preferred_content_size_category: &UIContentSizeCategory,
425        );
426
427        #[cfg(feature = "UIInterface")]
428        #[unsafe(method(displayGamut))]
429        #[unsafe(method_family = none)]
430        unsafe fn displayGamut(&self) -> UIDisplayGamut;
431
432        #[cfg(feature = "UIInterface")]
433        /// Setter for [`displayGamut`][Self::displayGamut].
434        #[unsafe(method(setDisplayGamut:))]
435        #[unsafe(method_family = none)]
436        unsafe fn setDisplayGamut(&self, display_gamut: UIDisplayGamut);
437
438        #[cfg(feature = "UIInterface")]
439        #[unsafe(method(accessibilityContrast))]
440        #[unsafe(method_family = none)]
441        unsafe fn accessibilityContrast(&self) -> UIAccessibilityContrast;
442
443        #[cfg(feature = "UIInterface")]
444        /// Setter for [`accessibilityContrast`][Self::accessibilityContrast].
445        #[unsafe(method(setAccessibilityContrast:))]
446        #[unsafe(method_family = none)]
447        unsafe fn setAccessibilityContrast(&self, accessibility_contrast: UIAccessibilityContrast);
448
449        #[cfg(feature = "UIInterface")]
450        #[unsafe(method(userInterfaceLevel))]
451        #[unsafe(method_family = none)]
452        unsafe fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
453
454        #[cfg(feature = "UIInterface")]
455        /// Setter for [`userInterfaceLevel`][Self::userInterfaceLevel].
456        #[unsafe(method(setUserInterfaceLevel:))]
457        #[unsafe(method_family = none)]
458        unsafe fn setUserInterfaceLevel(&self, user_interface_level: UIUserInterfaceLevel);
459
460        #[cfg(feature = "UIInterface")]
461        #[unsafe(method(legibilityWeight))]
462        #[unsafe(method_family = none)]
463        unsafe fn legibilityWeight(&self) -> UILegibilityWeight;
464
465        #[cfg(feature = "UIInterface")]
466        /// Setter for [`legibilityWeight`][Self::legibilityWeight].
467        #[unsafe(method(setLegibilityWeight:))]
468        #[unsafe(method_family = none)]
469        unsafe fn setLegibilityWeight(&self, legibility_weight: UILegibilityWeight);
470
471        #[cfg(feature = "UIInterface")]
472        #[unsafe(method(activeAppearance))]
473        #[unsafe(method_family = none)]
474        unsafe fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
475
476        #[cfg(feature = "UIInterface")]
477        /// Setter for [`activeAppearance`][Self::activeAppearance].
478        #[unsafe(method(setActiveAppearance:))]
479        #[unsafe(method_family = none)]
480        unsafe fn setActiveAppearance(&self, active_appearance: UIUserInterfaceActiveAppearance);
481
482        #[cfg(feature = "UIInterface")]
483        #[unsafe(method(toolbarItemPresentationSize))]
484        #[unsafe(method_family = none)]
485        unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
486
487        #[cfg(feature = "UIInterface")]
488        /// Setter for [`toolbarItemPresentationSize`][Self::toolbarItemPresentationSize].
489        #[unsafe(method(setToolbarItemPresentationSize:))]
490        #[unsafe(method_family = none)]
491        unsafe fn setToolbarItemPresentationSize(
492            &self,
493            toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
494        );
495
496        #[cfg(feature = "UIInterface")]
497        #[unsafe(method(imageDynamicRange))]
498        #[unsafe(method_family = none)]
499        unsafe fn imageDynamicRange(&self) -> UIImageDynamicRange;
500
501        #[cfg(feature = "UIInterface")]
502        /// Setter for [`imageDynamicRange`][Self::imageDynamicRange].
503        #[unsafe(method(setImageDynamicRange:))]
504        #[unsafe(method_family = none)]
505        unsafe fn setImageDynamicRange(&self, image_dynamic_range: UIImageDynamicRange);
506
507        #[cfg(feature = "UISceneDefinitions")]
508        #[unsafe(method(sceneCaptureState))]
509        #[unsafe(method_family = none)]
510        unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
511
512        #[cfg(feature = "UISceneDefinitions")]
513        /// Setter for [`sceneCaptureState`][Self::sceneCaptureState].
514        #[unsafe(method(setSceneCaptureState:))]
515        #[unsafe(method_family = none)]
516        unsafe fn setSceneCaptureState(&self, scene_capture_state: UISceneCaptureState);
517
518        #[unsafe(method(typesettingLanguage))]
519        #[unsafe(method_family = none)]
520        unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
521
522        /// Setter for [`typesettingLanguage`][Self::typesettingLanguage].
523        #[unsafe(method(setTypesettingLanguage:))]
524        #[unsafe(method_family = none)]
525        unsafe fn setTypesettingLanguage(&self, typesetting_language: &NSString);
526
527        #[cfg(feature = "UITraitListEnvironment")]
528        #[unsafe(method(listEnvironment))]
529        #[unsafe(method_family = none)]
530        unsafe fn listEnvironment(&self) -> UIListEnvironment;
531
532        #[cfg(feature = "UITraitListEnvironment")]
533        /// Setter for [`listEnvironment`][Self::listEnvironment].
534        #[unsafe(method(setListEnvironment:))]
535        #[unsafe(method_family = none)]
536        unsafe fn setListEnvironment(&self, list_environment: UIListEnvironment);
537    }
538);
539
540/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitmutations?language=objc)
541#[cfg(feature = "block2")]
542pub type UITraitMutations =
543    *mut block2::Block<dyn Fn(NonNull<ProtocolObject<dyn UIMutableTraits>>)>;
544
545impl UITraitCollection {
546    extern_methods!(
547        #[cfg(feature = "block2")]
548        #[unsafe(method(traitCollectionWithTraits:))]
549        #[unsafe(method_family = none)]
550        pub unsafe fn traitCollectionWithTraits(
551            mutations: UITraitMutations,
552        ) -> Retained<UITraitCollection>;
553
554        #[cfg(feature = "block2")]
555        #[unsafe(method(traitCollectionByModifyingTraits:))]
556        #[unsafe(method_family = none)]
557        pub unsafe fn traitCollectionByModifyingTraits(
558            &self,
559            mutations: UITraitMutations,
560        ) -> Retained<UITraitCollection>;
561
562        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
563        #[unsafe(method(traitCollectionWithCGFloatValue:forTrait:))]
564        #[unsafe(method_family = none)]
565        pub unsafe fn traitCollectionWithCGFloatValue_forTrait(
566            value: CGFloat,
567            r#trait: &UICGFloatTrait,
568        ) -> Retained<UITraitCollection>;
569
570        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
571        #[unsafe(method(traitCollectionByReplacingCGFloatValue:forTrait:))]
572        #[unsafe(method_family = none)]
573        pub unsafe fn traitCollectionByReplacingCGFloatValue_forTrait(
574            &self,
575            value: CGFloat,
576            r#trait: &UICGFloatTrait,
577        ) -> Retained<UITraitCollection>;
578
579        #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
580        #[unsafe(method(valueForCGFloatTrait:))]
581        #[unsafe(method_family = none)]
582        pub unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
583
584        #[cfg(feature = "UITrait")]
585        #[unsafe(method(traitCollectionWithNSIntegerValue:forTrait:))]
586        #[unsafe(method_family = none)]
587        pub unsafe fn traitCollectionWithNSIntegerValue_forTrait(
588            value: NSInteger,
589            r#trait: &UINSIntegerTrait,
590        ) -> Retained<UITraitCollection>;
591
592        #[cfg(feature = "UITrait")]
593        #[unsafe(method(traitCollectionByReplacingNSIntegerValue:forTrait:))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn traitCollectionByReplacingNSIntegerValue_forTrait(
596            &self,
597            value: NSInteger,
598            r#trait: &UINSIntegerTrait,
599        ) -> Retained<UITraitCollection>;
600
601        #[cfg(feature = "UITrait")]
602        #[unsafe(method(valueForNSIntegerTrait:))]
603        #[unsafe(method_family = none)]
604        pub unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
605
606        #[cfg(feature = "UITrait")]
607        #[unsafe(method(traitCollectionWithObject:forTrait:))]
608        #[unsafe(method_family = none)]
609        pub unsafe fn traitCollectionWithObject_forTrait(
610            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
611            r#trait: &UIObjectTrait,
612        ) -> Retained<UITraitCollection>;
613
614        #[cfg(feature = "UITrait")]
615        #[unsafe(method(traitCollectionByReplacingObject:forTrait:))]
616        #[unsafe(method_family = none)]
617        pub unsafe fn traitCollectionByReplacingObject_forTrait(
618            &self,
619            object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
620            r#trait: &UIObjectTrait,
621        ) -> Retained<UITraitCollection>;
622
623        #[cfg(feature = "UITrait")]
624        #[unsafe(method(objectForTrait:))]
625        #[unsafe(method_family = none)]
626        pub unsafe fn objectForTrait(
627            &self,
628            r#trait: &UIObjectTrait,
629        ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
630    );
631}
632
633extern_protocol!(
634    /// Trait environments expose a trait collection that describes their environment.
635    ///
636    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitenvironment?language=objc)
637    pub unsafe trait UITraitEnvironment: NSObjectProtocol + MainThreadOnly {
638        #[unsafe(method(traitCollection))]
639        #[unsafe(method_family = none)]
640        fn traitCollection(&self) -> Retained<UITraitCollection>;
641
642        /// To be overridden as needed to provide custom behavior when the environment's traits change.
643        #[deprecated = "Use the trait change registration APIs declared in the UITraitChangeObservable protocol"]
644        #[unsafe(method(traitCollectionDidChange:))]
645        #[unsafe(method_family = none)]
646        unsafe fn traitCollectionDidChange(
647            &self,
648            previous_trait_collection: Option<&UITraitCollection>,
649        );
650    }
651);
652
653extern_protocol!(
654    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangeregistration?language=objc)
655    pub unsafe trait UITraitChangeRegistration:
656        NSObjectProtocol + NSCopying + MainThreadOnly
657    {
658    }
659);
660
661/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangehandler?language=objc)
662#[cfg(feature = "block2")]
663pub type UITraitChangeHandler = *mut block2::Block<
664    dyn Fn(NonNull<ProtocolObject<dyn UITraitEnvironment>>, NonNull<UITraitCollection>),
665>;
666
667extern_protocol!(
668    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitoverrides?language=objc)
669    pub unsafe trait UITraitOverrides: UIMutableTraits + MainThreadOnly {
670        #[cfg(feature = "UITrait")]
671        #[unsafe(method(containsTrait:))]
672        #[unsafe(method_family = none)]
673        unsafe fn containsTrait(&self, r#trait: &UITrait) -> bool;
674
675        #[cfg(feature = "UITrait")]
676        #[unsafe(method(removeTrait:))]
677        #[unsafe(method_family = none)]
678        unsafe fn removeTrait(&self, r#trait: &UITrait);
679    }
680);
681
682extern_protocol!(
683    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitraitchangeobservable?language=objc)
684    pub unsafe trait UITraitChangeObservable: MainThreadOnly {
685        #[unsafe(method(unregisterForTraitChanges:))]
686        #[unsafe(method_family = none)]
687        unsafe fn unregisterForTraitChanges(
688            &self,
689            registration: &ProtocolObject<dyn UITraitChangeRegistration>,
690        );
691    }
692);
693
694/// CurrentTraitCollection.
695impl UITraitCollection {
696    extern_methods!(
697        #[unsafe(method(currentTraitCollection))]
698        #[unsafe(method_family = none)]
699        pub unsafe fn currentTraitCollection() -> Retained<UITraitCollection>;
700
701        /// Setter for [`currentTraitCollection`][Self::currentTraitCollection].
702        #[unsafe(method(setCurrentTraitCollection:))]
703        #[unsafe(method_family = none)]
704        pub unsafe fn setCurrentTraitCollection(current_trait_collection: &UITraitCollection);
705
706        #[cfg(feature = "block2")]
707        #[unsafe(method(performAsCurrentTraitCollection:))]
708        #[unsafe(method_family = none)]
709        pub unsafe fn performAsCurrentTraitCollection(
710            &self,
711            actions: &block2::Block<dyn Fn() + '_>,
712        );
713    );
714}
715
716/// DynamicAppearance.
717impl UITraitCollection {
718    extern_methods!(
719        #[unsafe(method(hasDifferentColorAppearanceComparedToTraitCollection:))]
720        #[unsafe(method_family = none)]
721        pub unsafe fn hasDifferentColorAppearanceComparedToTraitCollection(
722            &self,
723            trait_collection: Option<&UITraitCollection>,
724        ) -> bool;
725    );
726}
727
728/// ImageConfiguration.
729impl UITraitCollection {
730    extern_methods!(
731        #[cfg(feature = "UIImageConfiguration")]
732        #[unsafe(method(imageConfiguration))]
733        #[unsafe(method_family = none)]
734        pub unsafe fn imageConfiguration(&self) -> Retained<UIImageConfiguration>;
735    );
736}