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
use kas::{event, prelude::*};
#[derive(Clone, Debug, Default, Widget)]
pub struct Filler {
#[widget_core]
core: CoreData,
horiz: Stretch,
vert: Stretch,
}
impl Layout for Filler {
fn size_rules(&mut self, _: &mut dyn SizeHandle, axis: AxisInfo) -> SizeRules {
let stretch = if axis.is_horizontal() {
self.horiz
} else {
self.vert
};
SizeRules::empty(stretch)
}
fn draw(&self, _: &mut dyn DrawHandle, _: &event::ManagerState, _: bool) {}
}
impl Filler {
pub fn new() -> Self {
Filler::with(Stretch::Filler)
}
pub fn low() -> Self {
Filler::with(Stretch::Low)
}
pub fn high() -> Self {
Filler::with(Stretch::High)
}
pub fn maximize() -> Self {
Filler::with(Stretch::Maximize)
}
pub fn with(stretch: Stretch) -> Self {
Filler::with_hv(stretch, stretch)
}
pub fn with_hv(horiz: Stretch, vert: Stretch) -> Self {
let core = Default::default();
Filler { core, horiz, vert }
}
}