objc2_ui_kit/generated/
UIScreen.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#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15extern "C" {
16    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreendidconnectnotification?language=objc)
17    pub static UIScreenDidConnectNotification: &'static NSNotificationName;
18}
19
20extern "C" {
21    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreendiddisconnectnotification?language=objc)
22    pub static UIScreenDidDisconnectNotification: &'static NSNotificationName;
23}
24
25extern "C" {
26    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenmodedidchangenotification?language=objc)
27    pub static UIScreenModeDidChangeNotification: &'static NSNotificationName;
28}
29
30extern "C" {
31    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenbrightnessdidchangenotification?language=objc)
32    pub static UIScreenBrightnessDidChangeNotification: &'static NSNotificationName;
33}
34
35extern "C" {
36    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreencaptureddidchangenotification?language=objc)
37    pub static UIScreenCapturedDidChangeNotification: &'static NSNotificationName;
38}
39
40extern "C" {
41    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenreferencedisplaymodestatusdidchangenotification?language=objc)
42    pub static UIScreenReferenceDisplayModeStatusDidChangeNotification: &'static NSNotificationName;
43}
44
45/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenoverscancompensation?language=objc)
46// NS_ENUM
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct UIScreenOverscanCompensation(pub NSInteger);
50impl UIScreenOverscanCompensation {
51    #[doc(alias = "UIScreenOverscanCompensationScale")]
52    pub const Scale: Self = Self(0);
53    #[doc(alias = "UIScreenOverscanCompensationInsetBounds")]
54    pub const InsetBounds: Self = Self(1);
55    #[doc(alias = "UIScreenOverscanCompensationNone")]
56    pub const None: Self = Self(2);
57    #[deprecated]
58    #[doc(alias = "UIScreenOverscanCompensationInsetApplicationFrame")]
59    pub const InsetApplicationFrame: Self = Self(2);
60}
61
62unsafe impl Encode for UIScreenOverscanCompensation {
63    const ENCODING: Encoding = NSInteger::ENCODING;
64}
65
66unsafe impl RefEncode for UIScreenOverscanCompensation {
67    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreenreferencedisplaymodestatus?language=objc)
71// NS_ENUM
72#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct UIScreenReferenceDisplayModeStatus(pub NSInteger);
75impl UIScreenReferenceDisplayModeStatus {
76    #[doc(alias = "UIScreenReferenceDisplayModeStatusNotSupported")]
77    pub const NotSupported: Self = Self(0);
78    #[doc(alias = "UIScreenReferenceDisplayModeStatusNotEnabled")]
79    pub const NotEnabled: Self = Self(1);
80    #[doc(alias = "UIScreenReferenceDisplayModeStatusLimited")]
81    pub const Limited: Self = Self(2);
82    #[doc(alias = "UIScreenReferenceDisplayModeStatusEnabled")]
83    pub const Enabled: Self = Self(3);
84}
85
86unsafe impl Encode for UIScreenReferenceDisplayModeStatus {
87    const ENCODING: Encoding = NSInteger::ENCODING;
88}
89
90unsafe impl RefEncode for UIScreenReferenceDisplayModeStatus {
91    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92}
93
94extern_class!(
95    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiscreen?language=objc)
96    #[unsafe(super(NSObject))]
97    #[thread_kind = MainThreadOnly]
98    #[derive(Debug, PartialEq, Eq, Hash)]
99    pub struct UIScreen;
100);
101
102unsafe impl NSObjectProtocol for UIScreen {}
103
104#[cfg(feature = "UITraitCollection")]
105unsafe impl UITraitEnvironment for UIScreen {}
106
107impl UIScreen {
108    extern_methods!(
109        #[deprecated = "Use UIApplication.shared.openSessions to find open sessions with scenes from other screens"]
110        #[unsafe(method(screens))]
111        #[unsafe(method_family = none)]
112        pub fn screens(mtm: MainThreadMarker) -> Retained<NSArray<UIScreen>>;
113
114        #[deprecated = "Use a UIScreen instance found through context instead: i.e, view.window.windowScene.screen"]
115        #[unsafe(method(mainScreen))]
116        #[unsafe(method_family = none)]
117        pub fn mainScreen(mtm: MainThreadMarker) -> Retained<UIScreen>;
118
119        #[cfg(feature = "objc2-core-foundation")]
120        #[unsafe(method(bounds))]
121        #[unsafe(method_family = none)]
122        pub fn bounds(&self) -> CGRect;
123
124        #[cfg(feature = "objc2-core-foundation")]
125        #[unsafe(method(scale))]
126        #[unsafe(method_family = none)]
127        pub fn scale(&self) -> CGFloat;
128
129        #[cfg(feature = "UIScreenMode")]
130        #[unsafe(method(availableModes))]
131        #[unsafe(method_family = none)]
132        pub fn availableModes(&self) -> Retained<NSArray<UIScreenMode>>;
133
134        #[cfg(feature = "UIScreenMode")]
135        #[unsafe(method(preferredMode))]
136        #[unsafe(method_family = none)]
137        pub fn preferredMode(&self) -> Option<Retained<UIScreenMode>>;
138
139        #[cfg(feature = "UIScreenMode")]
140        #[unsafe(method(currentMode))]
141        #[unsafe(method_family = none)]
142        pub fn currentMode(&self) -> Option<Retained<UIScreenMode>>;
143
144        #[cfg(feature = "UIScreenMode")]
145        /// Setter for [`currentMode`][Self::currentMode].
146        #[unsafe(method(setCurrentMode:))]
147        #[unsafe(method_family = none)]
148        pub fn setCurrentMode(&self, current_mode: Option<&UIScreenMode>);
149
150        #[unsafe(method(overscanCompensation))]
151        #[unsafe(method_family = none)]
152        pub fn overscanCompensation(&self) -> UIScreenOverscanCompensation;
153
154        /// Setter for [`overscanCompensation`][Self::overscanCompensation].
155        #[unsafe(method(setOverscanCompensation:))]
156        #[unsafe(method_family = none)]
157        pub fn setOverscanCompensation(&self, overscan_compensation: UIScreenOverscanCompensation);
158
159        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
160        #[unsafe(method(overscanCompensationInsets))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn overscanCompensationInsets(&self) -> UIEdgeInsets;
163
164        #[unsafe(method(mirroredScreen))]
165        #[unsafe(method_family = none)]
166        pub fn mirroredScreen(&self) -> Option<Retained<UIScreen>>;
167
168        #[deprecated = "Use the sceneCaptureState in UITraitCollection instead."]
169        #[unsafe(method(isCaptured))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn isCaptured(&self) -> bool;
172
173        #[cfg(feature = "objc2-core-foundation")]
174        #[unsafe(method(brightness))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn brightness(&self) -> CGFloat;
177
178        #[cfg(feature = "objc2-core-foundation")]
179        /// Setter for [`brightness`][Self::brightness].
180        #[unsafe(method(setBrightness:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn setBrightness(&self, brightness: CGFloat);
183
184        #[unsafe(method(wantsSoftwareDimming))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn wantsSoftwareDimming(&self) -> bool;
187
188        /// Setter for [`wantsSoftwareDimming`][Self::wantsSoftwareDimming].
189        #[unsafe(method(setWantsSoftwareDimming:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setWantsSoftwareDimming(&self, wants_software_dimming: bool);
192
193        #[cfg(feature = "UIView")]
194        #[unsafe(method(coordinateSpace))]
195        #[unsafe(method_family = none)]
196        pub fn coordinateSpace(&self) -> Retained<ProtocolObject<dyn UICoordinateSpace>>;
197
198        #[cfg(feature = "UIView")]
199        #[unsafe(method(fixedCoordinateSpace))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn fixedCoordinateSpace(
202            &self,
203        ) -> Retained<ProtocolObject<dyn UICoordinateSpace>>;
204
205        #[cfg(feature = "objc2-core-foundation")]
206        #[unsafe(method(nativeBounds))]
207        #[unsafe(method_family = none)]
208        pub fn nativeBounds(&self) -> CGRect;
209
210        #[cfg(feature = "objc2-core-foundation")]
211        #[unsafe(method(nativeScale))]
212        #[unsafe(method_family = none)]
213        pub fn nativeScale(&self) -> CGFloat;
214
215        #[cfg(feature = "objc2-quartz-core")]
216        #[cfg(not(target_os = "watchos"))]
217        #[unsafe(method(displayLinkWithTarget:selector:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn displayLinkWithTarget_selector(
220            &self,
221            target: &AnyObject,
222            sel: Sel,
223        ) -> Option<Retained<CADisplayLink>>;
224
225        #[unsafe(method(maximumFramesPerSecond))]
226        #[unsafe(method_family = none)]
227        pub fn maximumFramesPerSecond(&self) -> NSInteger;
228
229        #[cfg(feature = "objc2-core-foundation")]
230        #[unsafe(method(calibratedLatency))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn calibratedLatency(&self) -> CFTimeInterval;
233
234        #[unsafe(method(referenceDisplayModeStatus))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn referenceDisplayModeStatus(&self) -> UIScreenReferenceDisplayModeStatus;
237
238        #[cfg(feature = "objc2-core-foundation")]
239        #[unsafe(method(currentEDRHeadroom))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn currentEDRHeadroom(&self) -> CGFloat;
242
243        #[cfg(feature = "objc2-core-foundation")]
244        #[unsafe(method(potentialEDRHeadroom))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn potentialEDRHeadroom(&self) -> CGFloat;
247
248        #[cfg(feature = "UIFocus")]
249        #[deprecated = "Use -[UIWindowScene focusSystem].focusedItem instead"]
250        #[unsafe(method(focusedItem))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn focusedItem(&self) -> Option<Retained<ProtocolObject<dyn UIFocusItem>>>;
253
254        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
255        #[deprecated = "Use -[UIWindowScene focusSystem].focusedItem instead"]
256        #[unsafe(method(focusedView))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn focusedView(&self) -> Option<Retained<UIView>>;
259
260        #[deprecated = "Use -[UIWindowScene focusSystem] != nil instead"]
261        #[unsafe(method(supportsFocus))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn supportsFocus(&self) -> bool;
264
265        #[cfg(feature = "objc2-core-foundation")]
266        #[deprecated]
267        #[unsafe(method(applicationFrame))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn applicationFrame(&self) -> CGRect;
270    );
271}
272
273/// Methods declared on superclass `NSObject`.
274impl UIScreen {
275    extern_methods!(
276        #[unsafe(method(init))]
277        #[unsafe(method_family = init)]
278        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
279
280        #[unsafe(method(new))]
281        #[unsafe(method_family = new)]
282        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
283    );
284}
285
286/// UISnapshotting.
287impl UIScreen {
288    extern_methods!(
289        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
290        #[unsafe(method(snapshotViewAfterScreenUpdates:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn snapshotViewAfterScreenUpdates(
293            &self,
294            after_updates: bool,
295        ) -> Retained<UIView>;
296    );
297}