mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
Changes relevant to Winit: - `icrate` has been deprecated in favour of separate crates per framework, in our case `objc2-foundation` and `objc2-app-kit` (and in the future `objc2-ui-kit` on iOS). - Moved `MainThreadMarker::run_on_main` to free-standing function `run_on_main`. - Changed how features work, this should result in less code that we need to compile. - Enums are now real structs instead of type-aliases and free constants.
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use objc2::encode::{Encode, Encoding};
|
|
use objc2::rc::Id;
|
|
use objc2::{extern_class, extern_methods, msg_send_id, mutability, ClassType};
|
|
use objc2_foundation::{MainThreadMarker, NSInteger, NSObject};
|
|
|
|
extern_class!(
|
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
|
pub(crate) struct UIDevice;
|
|
|
|
unsafe impl ClassType for UIDevice {
|
|
type Super = NSObject;
|
|
type Mutability = mutability::InteriorMutable;
|
|
}
|
|
);
|
|
|
|
extern_methods!(
|
|
unsafe impl UIDevice {
|
|
pub fn current(_mtm: MainThreadMarker) -> Id<Self> {
|
|
unsafe { msg_send_id![Self::class(), currentDevice] }
|
|
}
|
|
|
|
#[method(userInterfaceIdiom)]
|
|
pub fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
|
|
}
|
|
);
|
|
|
|
#[repr(transparent)]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct UIUserInterfaceIdiom(NSInteger);
|
|
|
|
unsafe impl Encode for UIUserInterfaceIdiom {
|
|
const ENCODING: Encoding = NSInteger::ENCODING;
|
|
}
|
|
|
|
impl UIUserInterfaceIdiom {
|
|
pub const Unspecified: UIUserInterfaceIdiom = UIUserInterfaceIdiom(-1);
|
|
pub const Phone: UIUserInterfaceIdiom = UIUserInterfaceIdiom(0);
|
|
pub const Pad: UIUserInterfaceIdiom = UIUserInterfaceIdiom(1);
|
|
pub const TV: UIUserInterfaceIdiom = UIUserInterfaceIdiom(2);
|
|
pub const CarPlay: UIUserInterfaceIdiom = UIUserInterfaceIdiom(3);
|
|
}
|