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
use crate::gui::*;
pub struct WindowBuilder {
id: Id,
size: Vec2,
position: Vec2,
title: Option<String>,
is_static: bool,
}
impl WindowBuilder {
pub fn new(id: Id, size: Vec2) -> Self {
WindowBuilder {
id,
size,
position: Vec2::ZERO,
title: None,
is_static: false,
}
}
pub fn with_title(self, title: &str) -> Self {
WindowBuilder {
title: Some(title.to_string()),
..self
}
}
pub fn with_pos(self, position: Vec2, is_static: bool) -> Self {
WindowBuilder {
position,
is_static,
..self
}
}
pub fn with_centered_pos(self, is_static: bool) -> Self {
WindowBuilder {
position: get_centered_on_screen(self.size),
is_static,
..self
}
}
pub fn build<F: FnOnce(&mut Ui)>(&self, ui: &mut Ui, f: F) -> bool {
let window = widgets::Window::new(self.id, self.position, self.size)
.movable(self.is_static)
.titlebar(false);
if let Some(title) = &self.title {
return window.ui(ui, |ui| {
let gui_skins = storage::get::<GuiSkins>();
ui.push_skin(&gui_skins.window_title);
ui.label(None, title);
ui.pop_skin();
f(ui);
});
}
window.ui(ui, f)
}
}