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
use {
Backend,
Color,
Colorable,
Dimensions,
Frameable,
Scalar,
Sizeable,
Widget,
};
use widget;
#[derive(Copy, Clone, Debug)]
pub struct FramedRectangle {
pub common: widget::CommonBuilder,
pub style: Style,
}
pub const KIND: widget::Kind = "FramedRectangle";
widget_style!{
KIND;
style Style {
- color: Color { theme.shape_color }
- frame: Scalar { theme.frame_width }
- frame_color: Color { theme.frame_color }
}
}
impl FramedRectangle {
pub fn new(dim: Dimensions) -> Self {
FramedRectangle {
common: widget::CommonBuilder::new(),
style: Style::new(),
}.wh(dim)
}
builder_method!(pub with_style { style = Style });
}
impl Widget for FramedRectangle {
type State = ();
type Style = Style;
fn common(&self) -> &widget::CommonBuilder {
&self.common
}
fn common_mut(&mut self) -> &mut widget::CommonBuilder {
&mut self.common
}
fn unique_kind(&self) -> &'static str {
KIND
}
fn init_state(&self) -> () {
()
}
fn style(&self) -> Style {
self.style.clone()
}
fn update<B: Backend>(self, _args: widget::UpdateArgs<Self, B>) {
}
}
impl Colorable for FramedRectangle {
builder_method!(color { style.color = Some(Color) });
}
impl Frameable for FramedRectangle {
builder_methods!{
frame { style.frame = Some(Scalar) }
frame_color { style.frame_color = Some(Color) }
}
}