reverie_engine_opengl/window/
builder.rs

1use crate::window::Window;
2
3pub struct WindowConfig {
4    pub(crate) title: Option<String>,
5    pub(crate) width: u32,
6    pub(crate) height: u32,
7    pub(crate) maximize: bool,
8}
9
10impl WindowConfig {
11    pub(crate) const fn new() -> Self {
12        Self {
13            title: None,
14            width: 800,
15            height: 600,
16            maximize: false,
17        }
18    }
19}
20
21pub struct WindowBuilder {
22    config: WindowConfig,
23}
24
25impl WindowBuilder {
26    pub(crate) const fn new() -> Self {
27        Self {
28            config: WindowConfig::new(),
29        }
30    }
31
32    pub fn title(mut self, title: impl Into<String>) -> Self {
33        self.config.title = Some(title.into());
34        self
35    }
36
37    pub const fn size(mut self, width: u32, height: u32) -> Self {
38        self.config.width = width;
39        self.config.height = height;
40        self
41    }
42
43    pub const fn maximize(mut self) -> Self {
44        self.config.maximize = true;
45        self
46    }
47
48    #[cfg(feature = "winit")]
49    pub fn build(self) -> Window {
50        Window::new(self.config)
51    }
52}