mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 23:23:14 -04:00
* Upgrade to objc2 v0.4.0 and icrate v0.0.3 * Fix `touchBar` method * Use ClassType::alloc * Use #[method_id(...)] functionality in declare_class!
81 lines
2.3 KiB
Rust
81 lines
2.3 KiB
Rust
use icrate::Foundation::{CGFloat, CGRect, MainThreadMarker, NSArray, NSInteger, NSObject};
|
|
use objc2::encode::{Encode, Encoding};
|
|
use objc2::rc::Id;
|
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
|
|
|
use super::{UICoordinateSpace, UIScreenMode};
|
|
|
|
extern_class!(
|
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
|
pub(crate) struct UIScreen;
|
|
|
|
unsafe impl ClassType for UIScreen {
|
|
type Super = NSObject;
|
|
type Mutability = mutability::InteriorMutable;
|
|
}
|
|
);
|
|
|
|
extern_methods!(
|
|
unsafe impl UIScreen {
|
|
pub fn main(_mtm: MainThreadMarker) -> Id<Self> {
|
|
unsafe { msg_send_id![Self::class(), mainScreen] }
|
|
}
|
|
|
|
pub fn screens(_mtm: MainThreadMarker) -> Id<NSArray<Self>> {
|
|
unsafe { msg_send_id![Self::class(), screens] }
|
|
}
|
|
|
|
#[method(bounds)]
|
|
pub fn bounds(&self) -> CGRect;
|
|
|
|
#[method(scale)]
|
|
pub fn scale(&self) -> CGFloat;
|
|
|
|
#[method(nativeBounds)]
|
|
pub fn nativeBounds(&self) -> CGRect;
|
|
|
|
#[method(nativeScale)]
|
|
pub fn nativeScale(&self) -> CGFloat;
|
|
|
|
#[method(maximumFramesPerSecond)]
|
|
pub fn maximumFramesPerSecond(&self) -> NSInteger;
|
|
|
|
pub fn mirroredScreen(&self) -> Id<Self> {
|
|
unsafe { msg_send_id![Self::class(), mirroredScreen] }
|
|
}
|
|
|
|
pub fn preferredMode(&self) -> Option<Id<UIScreenMode>> {
|
|
unsafe { msg_send_id![self, preferredMode] }
|
|
}
|
|
|
|
#[method(setCurrentMode:)]
|
|
pub fn setCurrentMode(&self, mode: Option<&UIScreenMode>);
|
|
|
|
pub fn availableModes(&self) -> Id<NSArray<UIScreenMode>> {
|
|
unsafe { msg_send_id![self, availableModes] }
|
|
}
|
|
|
|
#[method(setOverscanCompensation:)]
|
|
pub fn setOverscanCompensation(&self, overscanCompensation: UIScreenOverscanCompensation);
|
|
|
|
pub fn coordinateSpace(&self) -> Id<UICoordinateSpace> {
|
|
unsafe { msg_send_id![self, coordinateSpace] }
|
|
}
|
|
}
|
|
);
|
|
|
|
#[repr(transparent)]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct UIScreenOverscanCompensation(NSInteger);
|
|
|
|
unsafe impl Encode for UIScreenOverscanCompensation {
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
impl UIScreenOverscanCompensation {
|
|
pub const Scale: Self = Self(0);
|
|
pub const InsetBounds: Self = Self(1);
|
|
pub const None: Self = Self(2);
|
|
}
|