Skip to main content

acute_window/
winit_window.rs

1use winit::dpi::LogicalSize;
2use winit::window::{Fullscreen, Window, WindowBuilder};
3use winit::event_loop::EventLoop;
4
5
6pub struct WindowDescriptor {
7    title: String,
8    size: LogicalSize<u32>,
9    fullscreen: Option<Fullscreen>,
10    resizable: bool,
11}
12
13impl Default for WindowDescriptor {
14    fn default() -> Self {
15        Self {
16            title: "Acute".to_string(),
17            size: LogicalSize { width: 1280, height: 720 },
18            fullscreen: None,
19            resizable: false
20        }
21    }
22}
23
24pub struct WinitWindow;
25
26impl WinitWindow {
27    pub fn new(window_desc: WindowDescriptor) -> (Window, EventLoop<()>) {
28        let event_loop = EventLoop::new();
29        let window = WindowBuilder::new()
30            .with_title(window_desc.title)
31            .with_inner_size(window_desc.size)
32            .with_fullscreen(window_desc.fullscreen)
33            .with_resizable(window_desc.resizable)
34            .build(&event_loop).unwrap();
35
36        (window, event_loop)
37    }
38
39    pub fn new_headless() -> EventLoop<()> {
40        let event_loop = EventLoop::new();
41        event_loop
42    }
43}