use std::sync::Arc;
use fj_viewer::{Screen, ScreenSize};
use winit::{event_loop::EventLoop, window::WindowBuilder};
pub struct Window {
inner: Arc<winit::window::Window>,
}
impl Window {
pub fn new<T>(event_loop: &EventLoop<T>) -> Result<Self, WindowError> {
let window = WindowBuilder::new()
.with_title("Fornjot")
.with_maximized(true)
.with_decorations(false)
.with_transparent(false)
.build(event_loop)?;
Ok(Self {
inner: Arc::new(window),
})
}
}
impl Screen for Window {
type Window = winit::window::Window;
fn size(&self) -> ScreenSize {
let size = self.inner.inner_size();
ScreenSize {
width: size.width,
height: size.height,
}
}
fn window(&self) -> Arc<Self::Window> {
self.inner.clone()
}
}
#[derive(Debug, thiserror::Error)]
#[error("Error initializing window")]
pub struct WindowError(#[from] pub winit::error::OsError);