use objc::{msg_send, sel, sel_impl};
use crate::{
core_graphics::CGFloat,
foundation::{
Int, NSAlignmentOptions, NSDictionary, NSEdgeInsets, NSNotificationName, NSRect, NSString,
NSTimeInterval,
},
object,
objective_c_runtime::{
id,
traits::{FromId, PNSObject},
},
utils::to_bool,
};
pub type NSDeviceDescriptionKey = NSString;
use super::{interface_impl, NSColorSpace, NSWindowDepth};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
#[repr(u64)]
pub enum NSDisplayGamut {
Srgb = 1,
P3,
}
extern "C" {
pub static NSScreenColorSpaceDidChangeNotification: NSNotificationName;
}
object! {
unsafe pub struct NSScreen;
}
#[interface_impl(NSObject)]
impl NSScreen {
#[property]
pub fn main_screen() -> NSScreen {
unsafe { NSScreen::from_id(msg_send![Self::m_class(), mainScreen]) }
}
#[property]
pub fn deepest_screen() -> NSScreen {
unsafe { NSScreen::from_id(msg_send![Self::m_class(), deepestScreen]) }
}
#[property]
pub fn screens() -> NSScreen {
unsafe { NSScreen::from_id(msg_send![Self::m_class(), screens]) }
}
#[property]
pub fn depth(&self) -> NSWindowDepth {
unsafe { msg_send![self.m_self(), depth] }
}
#[property]
pub fn frame(&self) -> NSRect {
unsafe { msg_send![self.m_self(), frame] }
}
#[property]
pub fn supported_window_depths(&self) -> *const NSWindowDepth {
unsafe { msg_send![self.m_self(), supportedWindowDepths] }
}
#[property]
pub fn device_description(&self) -> NSDictionary<NSDeviceDescriptionKey, id> {
unsafe { NSDictionary::from_id(msg_send![self.m_self(), deviceDescription]) }
}
#[deprecated]
#[method]
pub fn user_space_scale_factor(&self) -> CGFloat {
unsafe { msg_send![self.m_self(), userSpaceScaleFactor] }
}
#[property]
pub fn color_space(&self) -> NSColorSpace {
unsafe { NSColorSpace::from_id(msg_send![self.m_self(), colorSpace]) }
}
#[property]
pub fn localized_name(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), localizedName]) }
}
#[method]
pub fn can_represent_display_gamut(&self, display_gamut: NSDisplayGamut) -> bool {
unsafe {
to_bool(msg_send![
self.m_self(),
canRepresentDisplayGamut: display_gamut
])
}
}
#[property]
pub fn screens_have_separate_spaces() -> bool {
unsafe { to_bool(msg_send![Self::m_class(), screensHaveSeparateSpaces]) }
}
#[method]
pub fn backing_aligned_rect_options(
&self,
rect: NSRect,
options: NSAlignmentOptions,
) -> NSRect {
unsafe { msg_send![self.m_self(), backingAlignedRect: rect options: options] }
}
#[property]
pub fn backing_scale_factor(&self) -> CGFloat {
unsafe { msg_send![self.m_self(), backingScaleFactor] }
}
#[method]
pub fn convert_rect_from_backing(&self, rect: NSRect) -> NSRect {
unsafe { msg_send![self.m_self(), convertRectFromBacking: rect] }
}
#[method]
pub fn convert_rect_to_backing(&self, rect: NSRect) -> NSRect {
unsafe { msg_send![self.m_self(), convertRectToBacking: rect] }
}
#[property]
pub fn visible_frame(&self) -> NSRect {
unsafe { msg_send![self.m_self(), visibleFrame] }
}
#[property]
pub fn safe_area_insets(&self) -> NSEdgeInsets {
unsafe { msg_send![self.m_self(), safeAreaInsets] }
}
#[property]
pub fn maximum_potential_extended_dynamic_range_color_component_value(&self) -> CGFloat {
unsafe {
msg_send![
self.m_self(),
maximumPotentialExtendedDynamicRangeColorComponentValue
]
}
}
#[property]
pub fn maximum_extended_dynamic_range_color_component_value(&self) -> CGFloat {
unsafe {
msg_send![
self.m_self(),
maximumExtendedDynamicRangeColorComponentValue
]
}
}
#[property]
pub fn maximum_reference_extended_dynamic_range_color_component_value(&self) -> CGFloat {
unsafe {
msg_send![
self.m_self(),
maximumReferenceExtendedDynamicRangeColorComponentValue
]
}
}
#[property]
pub fn maximum_frames_per_second(&self) -> Int {
unsafe { msg_send![self.m_self(), maximumFramesPerSecond] }
}
#[property]
pub fn minimum_refresh_interval(&self) -> NSTimeInterval {
unsafe { msg_send![self.m_self(), minimumRefreshInterval] }
}
#[property]
pub fn maximum_refresh_interval(&self) -> NSTimeInterval {
unsafe { msg_send![self.m_self(), maximumRefreshInterval] }
}
#[property]
pub fn display_update_granularity(&self) -> NSTimeInterval {
unsafe { msg_send![self.m_self(), displayUpdateGranularity] }
}
#[property]
pub fn last_display_update_timestamp(&self) -> NSTimeInterval {
unsafe { msg_send![self.m_self(), lastDisplayUpdateTimestamp] }
}
#[property]
pub fn auxiliary_top_left_area(&self) -> NSRect {
unsafe { msg_send![self.m_self(), auxiliaryTopLeftArea] }
}
#[property]
pub fn auxiliary_top_right_area(&self) -> NSRect {
unsafe { msg_send![self.m_self(), auxiliaryTopRightArea] }
}
}