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
105
106
107
108
109
110
mod builder;
use super::prelude::*;
use super::event::Event;
pub use builder::WindowBuilder;
pub type StandardWindowEvent = Event<'static, WindowHandle>;
#[derive(Clone, Copy)]
pub struct WindowHandle {
pub(in super) inner: WindowImpl
}
#[derive(Default)]
pub(in crate) struct WindowEvents {
pub on_close: StandardWindowEvent,
pub on_destroy: StandardWindowEvent,
pub on_resize: Event<'static, WindowResizeEventArgs>
}
pub struct WindowResizeEventArgs {
handle: WindowHandle,
new_size: Dims2D
}
pub trait OwnedWindow {
fn window_handle( &self ) -> WindowHandle;
}
impl WindowHandle {
impl_prop!{ pub content_dimensions: ContentDimensions }
impl_prop!{ pub opacity: Opacity }
impl_prop!{ pub position: Position }
impl_prop!{ pub title: Title }
impl_prop!{ pub window_dimensions: WindowDimensions }
pub fn close( self ) {
self.hide();
}
pub fn hide( &self ) {
self.inner.hide()
}
pub(in super) fn new( inner: WindowImpl ) -> Self {
Self {
inner
}
}
pub fn show( &self ) {
self.inner.show()
}
}
prop! {
ContentDimensions<Dims2D>( this: WindowHandle ) {
get => this.inner.get_content_dimensions().into(),
set(val) => this.inner.set_content_dimensions( val.into() )
}
}
prop! {
Opacity<u8>( this: WindowHandle ) {
get => this.inner.get_opacity(),
set(val) => this.inner.set_opacity( val )
}
}
prop! {
Position<Pos2D>( this: WindowHandle ) {
get => this.inner.get_position(),
set(val) => this.inner.set_position( val )
}
}
prop!{
pub Title<String, &str>( this: WindowHandle ) {
get => this.inner.get_title(),
set(val) => this.inner.set_title( val ).into()
}
}
prop! {
WindowDimensions<Dims2D>( this: WindowHandle ) {
get => this.inner.get_window_dimensions().into(),
set(val) => this.inner.set_window_dimensions( val.into() )
}
}