1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use winit::dpi::LogicalSize;
use winit::window::{Fullscreen, Window, WindowBuilder};
use winit::event_loop::EventLoop;


pub struct WindowDescriptor {
    title: String,
    size: LogicalSize<u32>,
    fullscreen: Option<Fullscreen>,
    resizable: bool,
}

impl Default for WindowDescriptor {
    fn default() -> Self {
        Self {
            title: "Acute".to_string(),
            size: LogicalSize { width: 1280, height: 720 },
            fullscreen: None,
            resizable: false
        }
    }
}

pub struct WinitWindow;

impl WinitWindow {
    pub fn new(window_desc: WindowDescriptor) -> (Window, EventLoop<()>) {
        let event_loop = EventLoop::new();
        let window = WindowBuilder::new()
            .with_title(window_desc.title)
            .with_inner_size(window_desc.size)
            .with_fullscreen(window_desc.fullscreen)
            .with_resizable(window_desc.resizable)
            .build(&event_loop).unwrap();

        (window, event_loop)
    }
}