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
use raui_app::app::declarative::DeclarativeApp;
use raui_core::{
make_widget,
widget::{
component::{
containers::size_box::{SizeBoxProps, size_box},
image_box::{ImageBoxProps, image_box},
},
unit::size::SizeBoxSizeValue,
utils::Color,
},
};
fn main() {
let tree = make_widget!(size_box)
.with_props(SizeBoxProps {
// takes the layout box size from its children size. content size is the default one.
width: SizeBoxSizeValue::Content,
height: SizeBoxSizeValue::Content,
..Default::default()
})
.named_slot(
"content",
make_widget!(size_box)
.with_props(SizeBoxProps {
// exact size resets layout available size into size defined here.
// it simply ignores available size and uses this one down the widget tree.
width: SizeBoxSizeValue::Exact(400.0),
height: SizeBoxSizeValue::Exact(300.0),
..Default::default()
})
.named_slot(
"content",
make_widget!(size_box)
.with_props(SizeBoxProps {
// uses layout available size defined by this widget parent node.
width: SizeBoxSizeValue::Fill,
height: SizeBoxSizeValue::Fill,
// we can additionally set margin.
margin: 50.0.into(),
..Default::default()
})
.named_slot(
"content",
make_widget!(image_box).with_props(ImageBoxProps::colored(Color {
r: 1.0,
g: 0.25,
b: 0.25,
a: 1.0,
})),
),
),
);
DeclarativeApp::simple("Size Box", tree);
}