1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
#[cfg(not(target_os = "watchos"))]
use objc2_quartz_core::*;

use crate::*;

extern "C" {
    pub static UIScreenDidConnectNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIScreenDidDisconnectNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIScreenModeDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIScreenBrightnessDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIScreenCapturedDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    pub static UIScreenReferenceDisplayModeStatusDidChangeNotification: &'static NSNotificationName;
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIScreenOverscanCompensation(pub NSInteger);
impl UIScreenOverscanCompensation {
    #[doc(alias = "UIScreenOverscanCompensationScale")]
    pub const Scale: Self = Self(0);
    #[doc(alias = "UIScreenOverscanCompensationInsetBounds")]
    pub const InsetBounds: Self = Self(1);
    #[doc(alias = "UIScreenOverscanCompensationNone")]
    pub const None: Self = Self(2);
    #[deprecated]
    #[doc(alias = "UIScreenOverscanCompensationInsetApplicationFrame")]
    pub const InsetApplicationFrame: Self = Self(2);
}

unsafe impl Encode for UIScreenOverscanCompensation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIScreenOverscanCompensation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIScreenReferenceDisplayModeStatus(pub NSInteger);
impl UIScreenReferenceDisplayModeStatus {
    #[doc(alias = "UIScreenReferenceDisplayModeStatusNotSupported")]
    pub const NotSupported: Self = Self(0);
    #[doc(alias = "UIScreenReferenceDisplayModeStatusNotEnabled")]
    pub const NotEnabled: Self = Self(1);
    #[doc(alias = "UIScreenReferenceDisplayModeStatusLimited")]
    pub const Limited: Self = Self(2);
    #[doc(alias = "UIScreenReferenceDisplayModeStatusEnabled")]
    pub const Enabled: Self = Self(3);
}

unsafe impl Encode for UIScreenReferenceDisplayModeStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIScreenReferenceDisplayModeStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIScreen;

    unsafe impl ClassType for UIScreen {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for UIScreen {}

#[cfg(feature = "UITraitCollection")]
unsafe impl UITraitEnvironment for UIScreen {}

extern_methods!(
    unsafe impl UIScreen {
        #[deprecated = "Use UIApplication.shared.openSessions to find open sessions with scenes from other screens"]
        #[method_id(@__retain_semantics Other screens)]
        pub fn screens(mtm: MainThreadMarker) -> Retained<NSArray<UIScreen>>;

        #[deprecated = "Use a UIScreen instance found through context instead: i.e, view.window.windowScene.screen"]
        #[method_id(@__retain_semantics Other mainScreen)]
        pub fn mainScreen(mtm: MainThreadMarker) -> Retained<UIScreen>;

        #[method(bounds)]
        pub fn bounds(&self) -> CGRect;

        #[method(scale)]
        pub fn scale(&self) -> CGFloat;

        #[cfg(feature = "UIScreenMode")]
        #[method_id(@__retain_semantics Other availableModes)]
        pub fn availableModes(&self) -> Retained<NSArray<UIScreenMode>>;

        #[cfg(feature = "UIScreenMode")]
        #[method_id(@__retain_semantics Other preferredMode)]
        pub fn preferredMode(&self) -> Option<Retained<UIScreenMode>>;

        #[cfg(feature = "UIScreenMode")]
        #[method_id(@__retain_semantics Other currentMode)]
        pub fn currentMode(&self) -> Option<Retained<UIScreenMode>>;

        #[cfg(feature = "UIScreenMode")]
        #[method(setCurrentMode:)]
        pub fn setCurrentMode(&self, current_mode: Option<&UIScreenMode>);

        #[method(overscanCompensation)]
        pub fn overscanCompensation(&self) -> UIScreenOverscanCompensation;

        #[method(setOverscanCompensation:)]
        pub fn setOverscanCompensation(&self, overscan_compensation: UIScreenOverscanCompensation);

        #[cfg(feature = "UIGeometry")]
        #[method(overscanCompensationInsets)]
        pub unsafe fn overscanCompensationInsets(&self) -> UIEdgeInsets;

        #[method_id(@__retain_semantics Other mirroredScreen)]
        pub fn mirroredScreen(&self) -> Option<Retained<UIScreen>>;

        #[deprecated = "Use the sceneCaptureState in UITraitCollection instead."]
        #[method(isCaptured)]
        pub unsafe fn isCaptured(&self) -> bool;

        #[method(brightness)]
        pub unsafe fn brightness(&self) -> CGFloat;

        #[method(setBrightness:)]
        pub unsafe fn setBrightness(&self, brightness: CGFloat);

        #[method(wantsSoftwareDimming)]
        pub unsafe fn wantsSoftwareDimming(&self) -> bool;

        #[method(setWantsSoftwareDimming:)]
        pub unsafe fn setWantsSoftwareDimming(&self, wants_software_dimming: bool);

        #[cfg(feature = "UIView")]
        #[method_id(@__retain_semantics Other coordinateSpace)]
        pub fn coordinateSpace(&self) -> Retained<ProtocolObject<dyn UICoordinateSpace>>;

        #[cfg(feature = "UIView")]
        #[method_id(@__retain_semantics Other fixedCoordinateSpace)]
        pub unsafe fn fixedCoordinateSpace(
            &self,
        ) -> Retained<ProtocolObject<dyn UICoordinateSpace>>;

        #[method(nativeBounds)]
        pub fn nativeBounds(&self) -> CGRect;

        #[method(nativeScale)]
        pub fn nativeScale(&self) -> CGFloat;

        #[cfg(feature = "objc2-quartz-core")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Other displayLinkWithTarget:selector:)]
        pub unsafe fn displayLinkWithTarget_selector(
            &self,
            target: &AnyObject,
            sel: Sel,
        ) -> Option<Retained<CADisplayLink>>;

        #[method(maximumFramesPerSecond)]
        pub fn maximumFramesPerSecond(&self) -> NSInteger;

        #[method(referenceDisplayModeStatus)]
        pub unsafe fn referenceDisplayModeStatus(&self) -> UIScreenReferenceDisplayModeStatus;

        #[method(currentEDRHeadroom)]
        pub unsafe fn currentEDRHeadroom(&self) -> CGFloat;

        #[method(potentialEDRHeadroom)]
        pub unsafe fn potentialEDRHeadroom(&self) -> CGFloat;

        #[cfg(feature = "UIFocus")]
        #[deprecated = "Use -[UIWindowScene focusSystem].focusedItem instead"]
        #[method_id(@__retain_semantics Other focusedItem)]
        pub unsafe fn focusedItem(&self) -> Option<Retained<ProtocolObject<dyn UIFocusItem>>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[deprecated = "Use -[UIWindowScene focusSystem].focusedItem instead"]
        #[method_id(@__retain_semantics Other focusedView)]
        pub unsafe fn focusedView(&self) -> Option<Retained<UIView>>;

        #[deprecated = "Use -[UIWindowScene focusSystem] != nil instead"]
        #[method(supportsFocus)]
        pub unsafe fn supportsFocus(&self) -> bool;

        #[deprecated]
        #[method(applicationFrame)]
        pub unsafe fn applicationFrame(&self) -> CGRect;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIScreen {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_methods!(
    /// UISnapshotting
    unsafe impl UIScreen {
        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method_id(@__retain_semantics Other snapshotViewAfterScreenUpdates:)]
        pub unsafe fn snapshotViewAfterScreenUpdates(
            &self,
            after_updates: bool,
        ) -> Retained<UIView>;
    }
);