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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use crate::{Pos, PositionType, entity::*, Size};
pub struct WindowSize {
pub width: u32,
pub height: u32,
}
impl WindowSize {
pub fn new(width: u32, height: u32) -> Self {
Self { width, height }
}
}
pub struct Position {
pub x: u32,
pub y: u32,
}
impl Position {
pub fn new(x: u32, y: u32) -> Self {
Position { x, y }
}
}
pub struct WindowDescription {
pub title: String,
pub inner_size: WindowSize,
pub min_inner_size: WindowSize,
pub max_inner_size: Option<WindowSize>,
pub position: Option<Position>,
pub resizable: bool,
pub maximized: bool,
pub visible: bool,
pub transparent: bool,
pub decorations: bool,
pub always_on_top: bool,
pub icon: Option<Vec<u8>>,
pub icon_width: u32,
pub icon_height: u32,
}
impl Default for WindowDescription {
fn default() -> Self {
Self {
title: "Tuix Application".to_string(),
inner_size: WindowSize::new(800, 600),
min_inner_size: WindowSize::new(100, 100),
max_inner_size: None,
position: None,
resizable: true,
maximized: false,
visible: true,
transparent: false,
decorations: true,
always_on_top: false,
icon: None,
icon_width: 0,
icon_height: 0,
}
}
}
impl WindowDescription {
pub fn new() -> Self {
WindowDescription::default()
}
pub fn with_title(mut self, title: &str) -> Self {
self.title = title.to_string();
self
}
pub fn with_inner_size(mut self, width: u32, height: u32) -> Self {
self.inner_size = WindowSize::new(width, height);
self
}
pub fn with_min_inner_size(mut self, width: u32, height: u32) -> Self {
self.min_inner_size = WindowSize::new(width, height);
self
}
pub fn with_max_inner_size(mut self, width: u32, height: u32) -> Self {
self.max_inner_size = Some(WindowSize::new(width, height));
self
}
pub fn with_icon(mut self, icon: Vec<u8>, width: u32, height: u32) -> Self {
self.icon = Some(icon);
self.icon_width = width;
self.icon_height = height;
self
}
}