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
use raui_app::app::declarative::DeclarativeApp;
use raui_core::{
make_widget,
widget::{
component::{
containers::{
content_box::content_box,
responsive_box::{MediaQueryExpression, MediaQueryOrientation, responsive_box},
},
image_box::{ImageBoxProps, image_box},
text_box::{TextBoxProps, text_box},
},
unit::text::{TextBoxFont, TextBoxHorizontalAlign, TextBoxVerticalAlign},
utils::Color,
},
};
fn main() {
let tree = make_widget!(content_box)
.listed_slot(
// responsive box allows to select one of listed slot widgets to
// present, depending on which slot widget's media query expression
// passes. ordering of listed slots is important, the first one that
// passes will be used. media query expressions can be combined with
// logical operator expressions such as `and`, `or` and `not`.
// in case of default case, use `any` expression.
make_widget!(responsive_box)
.listed_slot(
make_widget!(image_box)
.key("landscape")
.with_props(MediaQueryExpression::ScreenOrientation(
MediaQueryOrientation::Landscape,
))
.with_props(ImageBoxProps::colored(Color {
r: 0.25,
g: 1.0,
b: 0.25,
a: 1.0,
})),
)
.listed_slot(make_widget!(image_box).key("portrait").with_props(
ImageBoxProps::colored(Color {
r: 0.25,
g: 0.25,
b: 1.0,
a: 1.0,
}),
)),
)
.listed_slot(make_widget!(text_box).with_props(TextBoxProps {
text: "Change window size to observe responsiveness".to_owned(),
font: TextBoxFont {
name: "./demos/hello-world/resources/verdana.ttf".to_owned(),
size: 64.0,
},
color: Color {
r: 0.25,
g: 0.0,
b: 0.0,
a: 1.0,
},
horizontal_align: TextBoxHorizontalAlign::Center,
vertical_align: TextBoxVerticalAlign::Middle,
..Default::default()
}));
DeclarativeApp::simple("Responsive Box", tree);
}