1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Deserialize, Serialize)]
9pub struct WindowConfig {
10 pub title: String,
12 pub width: u32,
14 pub height: u32,
16 pub resizable: bool,
18 pub fullscreen: bool,
20}
21
22#[derive(Debug)]
24pub struct Window {
25 config: WindowConfig,
27 handle: Option<WindowHandle>,
29}
30
31#[derive(Debug)]
33pub struct WindowHandle {
34 id: u32,
36}
37
38impl WindowConfig {
39 pub fn default(title: &str) -> Self {
47 Self { title: title.to_string(), width: 800, height: 600, resizable: true, fullscreen: false }
48 }
49}
50
51impl Window {
52 pub fn new(config: WindowConfig) -> Self {
60 Self { config, handle: None }
61 }
62
63 pub fn set_title(&mut self, title: &str) {
68 self.config.title = title.to_string();
69 }
71
72 pub fn set_size(&mut self, width: u32, height: u32) {
78 self.config.width = width;
79 self.config.height = height;
80 }
82
83 pub fn show(&mut self) {
85 }
87
88 pub fn hide(&mut self) {
90 }
92
93 pub fn close(&mut self) {
95 }
97
98 pub fn config(&self) -> &WindowConfig {
103 &self.config
104 }
105
106 pub fn handle(&self) -> Option<&WindowHandle> {
111 self.handle.as_ref()
112 }
113}