1use kas::prelude::*;
9
10#[impl_self]
11mod Filler {
12 #[derive(Clone, Debug, Default)]
17 #[widget]
18 pub struct Filler {
19 core: widget_core!(),
20 horiz: Stretch,
21 vert: Stretch,
22 }
23
24 impl Layout for Filler {
25 fn size_rules(&mut self, _: SizeCx, axis: AxisInfo) -> SizeRules {
26 let stretch = if axis.is_horizontal() { self.horiz } else { self.vert };
27 SizeRules::empty(stretch)
28 }
29
30 fn draw(&self, _: DrawCx) {}
31 }
32
33 impl Tile for Self {
34 fn role(&self, _: &mut dyn RoleCx) -> Role<'_> {
35 Role::None
36 }
37 }
38}
39
40impl Filler {
41 pub fn new() -> Self {
43 Filler::with(Stretch::Filler)
44 }
45
46 pub fn low() -> Self {
48 Filler::with(Stretch::Low)
49 }
50
51 pub fn high() -> Self {
53 Filler::with(Stretch::High)
54 }
55
56 pub fn maximize() -> Self {
58 Filler::with(Stretch::Maximize)
59 }
60
61 pub fn with(stretch: Stretch) -> Self {
63 Filler::with_hv(stretch, stretch)
64 }
65
66 pub fn with_hv(horiz: Stretch, vert: Stretch) -> Self {
68 let core = Default::default();
69 Filler { core, horiz, vert }
70 }
71}