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
12extern_class!(
13 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[unsafe(method(toolbarItemPresentationSize))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
304
305 #[cfg(feature = "UIInterface")]
306 #[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 #[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 #[unsafe(method(typesettingLanguage))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
339
340 #[cfg(feature = "UISceneDefinitions")]
341 #[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 #[unsafe(method(sceneCaptureState))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
359
360 #[cfg(feature = "UITraitListEnvironment")]
361 #[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 #[unsafe(method(listEnvironment))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn listEnvironment(&self) -> UIListEnvironment;
379
380 #[cfg(feature = "UITabAccessory")]
381 #[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 #[unsafe(method(tabAccessoryEnvironment))]
397 #[unsafe(method_family = none)]
398 pub unsafe fn tabAccessoryEnvironment(&self) -> UITabAccessoryEnvironment;
399
400 #[cfg(feature = "UISplitViewControllerLayoutEnvironment")]
401 #[unsafe(method(splitViewControllerLayoutEnvironment))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn splitViewControllerLayoutEnvironment(
411 &self,
412 ) -> UISplitViewControllerLayoutEnvironment;
413
414 #[cfg(feature = "UIInterface")]
415 #[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 #[unsafe(method(resolvesNaturalAlignmentWithBaseWritingDirection))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn resolvesNaturalAlignmentWithBaseWritingDirection(&self) -> bool;
451 );
452}
453
454impl 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 pub unsafe trait UIMutableTraits: NSObjectProtocol + MainThreadOnly {
473 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
474 #[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 #[unsafe(method(valueForCGFloatTrait:))]
486 #[unsafe(method_family = none)]
487 unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
488
489 #[cfg(feature = "UITrait")]
490 #[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 #[unsafe(method(valueForNSIntegerTrait:))]
502 #[unsafe(method_family = none)]
503 unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
504
505 #[cfg(feature = "UITrait")]
506 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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#[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 #[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 #[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 #[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 #[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 #[unsafe(method(valueForCGFloatTrait:))]
830 #[unsafe(method_family = none)]
831 pub unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
832
833 #[cfg(feature = "UITrait")]
834 #[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 #[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 #[unsafe(method(valueForNSIntegerTrait:))]
861 #[unsafe(method_family = none)]
862 pub unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
863
864 #[cfg(feature = "UITrait")]
865 #[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 #[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 #[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 pub unsafe trait UITraitEnvironment: NSObjectProtocol + MainThreadOnly {
907 #[unsafe(method(traitCollection))]
908 #[unsafe(method_family = none)]
909 fn traitCollection(&self) -> Retained<UITraitCollection>;
910
911 #[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 pub unsafe trait UITraitChangeRegistration:
922 NSObjectProtocol + NSCopying + MainThreadOnly
923 {
924 }
925);
926
927#[cfg(feature = "block2")]
929pub type UITraitChangeHandler = *mut block2::DynBlock<
930 dyn Fn(NonNull<ProtocolObject<dyn UITraitEnvironment>>, NonNull<UITraitCollection>),
931>;
932
933extern_protocol!(
934 pub unsafe trait UITraitOverrides: UIMutableTraits + MainThreadOnly {
936 #[cfg(feature = "UITrait")]
937 #[unsafe(method(containsTrait:))]
941 #[unsafe(method_family = none)]
942 unsafe fn containsTrait(&self, r#trait: &UITrait) -> bool;
943
944 #[cfg(feature = "UITrait")]
945 #[unsafe(method(removeTrait:))]
949 #[unsafe(method_family = none)]
950 unsafe fn removeTrait(&self, r#trait: &UITrait);
951 }
952);
953
954extern_protocol!(
955 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
966impl UITraitCollection {
968 extern_methods!(
969 #[unsafe(method(currentTraitCollection))]
975 #[unsafe(method_family = none)]
976 pub unsafe fn currentTraitCollection() -> Retained<UITraitCollection>;
977
978 #[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
994impl 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
1006impl UITraitCollection {
1008 extern_methods!(
1009 #[cfg(feature = "UIImageConfiguration")]
1010 #[unsafe(method(imageConfiguration))]
1016 #[unsafe(method_family = none)]
1017 pub unsafe fn imageConfiguration(&self) -> Retained<UIImageConfiguration>;
1018 );
1019}