use {
crate::{
event::Event,
input::mouse::MouseButton,
monitor::BackendMonitor,
},
dpi::{
PhysicalPosition,
PhysicalSize,
},
keyboard_types::{
Code,
KeyState,
},
std::sync::Arc,
};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WindowId(usize);
impl WindowId {
pub const fn to_raw(self) -> usize {
self.0
}
pub const fn from_raw(raw: usize) -> Self {
Self(raw)
}
}
impl std::fmt::Display for WindowId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
pub trait BackendWindow: Send + Sync {
fn id(&self) -> WindowId;
fn raw_window_handle(&self) -> crate::raw_window_handle::RawWindowHandle;
fn raw_display_handle(&self) -> crate::raw_window_handle::RawDisplayHandle;
fn next_event(&self) -> Option<Event>;
fn iter<'w>(&'w self) -> Box<dyn BackendEventIterator<'w> + 'w>;
fn monitor(&self) -> Arc<dyn BackendMonitor>;
fn close(&self);
fn is_closing(&self) -> bool;
fn request_redraw(&self);
fn title(&self) -> String;
fn scale_factor(&self) -> f64;
fn inner_size(&self) -> PhysicalSize<u32>;
fn outer_size(&self) -> PhysicalSize<u32>;
fn inner_position(&self) -> PhysicalPosition<i32>;
fn outer_position(&self) -> PhysicalPosition<i32>;
fn key(&self, keycode: Code) -> KeyState;
fn mouse(&self, button: MouseButton) -> KeyState;
fn shift_key(&self) -> KeyState;
fn ctrl_key(&self) -> KeyState;
fn alt_key(&self) -> KeyState;
fn super_key(&self) -> KeyState;
}
pub trait BackendEventIterator<'window>: Send + Sync {
fn next(&mut self) -> Option<Event>;
}
pub trait RawWindowHandle {}