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
104
use flo_binding::*;
pub trait FloWindowProperties {
fn title(&self) -> BindRef<String>;
fn size(&self) -> BindRef<(u64, u64)>;
fn fullscreen(&self) -> BindRef<bool>;
fn has_decorations(&self) -> BindRef<bool>;
fn mouse_pointer(&self) -> BindRef<MousePointer>;
}
#[derive(Clone, Copy, PartialEq)]
pub enum MousePointer {
None,
SystemDefault
}
impl FloWindowProperties for () {
fn title(&self) -> BindRef<String> { BindRef::from(bind("flo_draw".to_string())) }
fn size(&self) -> BindRef<(u64, u64)> { BindRef::from(bind((1024, 768))) }
fn fullscreen(&self) -> BindRef<bool> { BindRef::from(bind(false)) }
fn has_decorations(&self) -> BindRef<bool> { BindRef::from(bind(true)) }
fn mouse_pointer(&self) -> BindRef<MousePointer> { BindRef::from(bind(MousePointer::SystemDefault)) }
}
impl<'a> FloWindowProperties for &'a str {
fn title(&self) -> BindRef<String> { BindRef::from(bind(self.to_string())) }
fn size(&self) -> BindRef<(u64, u64)> { BindRef::from(bind((1024, 768))) }
fn fullscreen(&self) -> BindRef<bool> { BindRef::from(bind(false)) }
fn has_decorations(&self) -> BindRef<bool> { BindRef::from(bind(true)) }
fn mouse_pointer(&self) -> BindRef<MousePointer> { BindRef::from(bind(MousePointer::SystemDefault)) }
}
#[derive(Clone)]
pub struct WindowProperties {
pub title: BindRef<String>,
pub size: BindRef<(u64, u64)>,
pub fullscreen: BindRef<bool>,
pub has_decorations: BindRef<bool>,
pub mouse_pointer: BindRef<MousePointer>
}
impl WindowProperties {
pub fn from<T: FloWindowProperties>(properties: &T) -> WindowProperties {
WindowProperties {
title: properties.title(),
size: properties.size(),
fullscreen: properties.fullscreen(),
has_decorations: properties.has_decorations(),
mouse_pointer: properties.mouse_pointer()
}
}
}
impl FloWindowProperties for WindowProperties {
fn title(&self) -> BindRef<String> { self.title.clone() }
fn size(&self) -> BindRef<(u64, u64)> { self.size.clone() }
fn fullscreen(&self) -> BindRef<bool> { self.fullscreen.clone() }
fn has_decorations(&self) -> BindRef<bool> { self.has_decorations.clone() }
fn mouse_pointer(&self) -> BindRef<MousePointer> { self.mouse_pointer.clone() }
}