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
use raui_app::app::declarative::DeclarativeApp;
use raui_core::{
make_widget,
widget::{
component::{
containers::horizontal_box::{HorizontalBoxProps, horizontal_box},
image_box::{ImageBoxProps, image_box},
},
unit::flex::FlexBoxItemLayout,
utils::Color,
},
};
fn main() {
let tree = make_widget!(horizontal_box)
.with_props(HorizontalBoxProps {
separation: 50.0,
..Default::default()
})
.listed_slot(
make_widget!(image_box)
.with_props(ImageBoxProps::colored(Color {
r: 1.0,
g: 0.25,
b: 0.25,
a: 1.0,
}))
.with_props(FlexBoxItemLayout {
// basis sets exact width of the item.
basis: Some(100.0),
// weight of the item when its layout box has to grow in width.
grow: 0.5,
// weight of the item when its layout box has to shrink in width (0.0 means no shrinking).
shrink: 0.0,
..Default::default()
}),
)
.listed_slot(
make_widget!(image_box).with_props(ImageBoxProps::colored(Color {
r: 0.25,
g: 1.0,
b: 0.25,
a: 1.0,
})),
)
.listed_slot(
make_widget!(image_box)
.with_props(ImageBoxProps::colored(Color {
r: 0.25,
g: 0.25,
b: 1.0,
a: 1.0,
}))
.with_props(FlexBoxItemLayout {
basis: Some(100.0),
grow: 0.0,
shrink: 0.5,
..Default::default()
}),
);
DeclarativeApp::simple("Horizontal Box", tree);
}