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
use raui_app::app::declarative::DeclarativeApp;
use raui_core::{
make_widget,
widget::{
component::{
containers::{
flex_box::{FlexBoxProps, flex_box},
size_box::{SizeBoxProps, size_box},
},
image_box::{ImageBoxProps, image_box},
text_box::{TextBoxProps, text_box},
},
unit::{
flex::{FlexBoxDirection, FlexBoxItemLayout},
image::{ImageBoxColor, ImageBoxMaterial, ImageBoxSizeValue},
size::SizeBoxSizeValue,
text::{TextBoxFont, TextBoxSizeValue},
},
utils::Color,
},
};
fn main() {
let tree = make_widget!(size_box)
.with_props(SizeBoxProps {
width: SizeBoxSizeValue::Fill,
height: SizeBoxSizeValue::Content,
..Default::default()
})
.named_slot(
"content",
make_widget!(flex_box)
.with_props(FlexBoxProps {
direction: FlexBoxDirection::VerticalTopToBottom,
..Default::default()
})
.listed_slot(
make_widget!(text_box)
.with_props(FlexBoxItemLayout::no_growing_and_shrinking())
.with_props(TextBoxProps {
text: "Hello\nWorld!".to_owned(),
font: TextBoxFont {
name: "./demos/hello-world/resources/verdana.ttf".to_owned(),
size: 64.0,
},
color: Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 1.0,
},
height: TextBoxSizeValue::Content,
..Default::default()
}),
)
.listed_slot(
make_widget!(image_box)
.with_props(FlexBoxItemLayout::no_growing_and_shrinking())
.with_props(ImageBoxProps {
height: ImageBoxSizeValue::Exact(100.0),
material: ImageBoxMaterial::Color(ImageBoxColor {
color: Color {
r: 1.0,
g: 0.5,
b: 0.0,
a: 1.0,
},
..Default::default()
}),
..Default::default()
}),
)
// this image should not be visible at all, a zero size layout.
.listed_slot(
make_widget!(image_box).with_props(ImageBoxProps::colored(Color {
r: 0.5,
g: 0.5,
b: 0.5,
a: 1.0,
})),
),
);
DeclarativeApp::simple("Flex Box - Adaptive content size", tree);
}