use std::num::NonZeroU32;
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
pub trait MapWindow {
fn size(&self) -> WindowSize;
}
pub trait HeadedMapWindow: MapWindow {
type RawWindow: HasRawWindowHandle + HasRawDisplayHandle;
fn raw(&self) -> &Self::RawWindow;
fn request_redraw(&self);
fn id(&self) -> u64;
}
pub trait MapWindowConfig: 'static {
type MapWindow: MapWindow;
fn create(&self) -> Self::MapWindow;
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub struct WindowSize {
width: NonZeroU32,
height: NonZeroU32,
}
impl WindowSize {
pub fn new(width: u32, height: u32) -> Option<Self> {
Some(Self {
width: NonZeroU32::new(width)?,
height: NonZeroU32::new(height)?,
})
}
pub fn width(&self) -> u32 {
self.width.get()
}
pub fn width_non_zero(&self) -> NonZeroU32 {
self.width
}
pub fn height(&self) -> u32 {
self.height.get()
}
pub fn height_non_zero(&self) -> NonZeroU32 {
self.height
}
}