-
Notifications
You must be signed in to change notification settings - Fork 193
/
stack.rs
112 lines (108 loc) · 4.04 KB
/
stack.rs
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use orbtk::prelude::*;
widget!(MainView);
impl Template for MainView {
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Stack::new()
.child(
TextBlock::new()
.margin((0.0, 0.0, 0.0, 8.0))
.text("Stack vertical")
.style("text_block_header")
.build(ctx),
)
.child(
Stack::new()
.spacing(4.0)
.child(
Button::new()
.style("button_single_content")
.text("left")
.h_align("start")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.text("center")
.h_align("center")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.text("stretch")
.h_align("stretch")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.text("right")
.h_align("end")
.build(ctx),
)
.build(ctx),
)
.child(
TextBlock::new()
.margin((0.0, 0.0, 0.0, 8.0))
.text("Stack horizontal")
.style("text_block_header")
.build(ctx),
)
.child(
Stack::new()
.orientation("horizontal")
.spacing(4.0)
.height(100.0)
.child(
Button::new()
.style("button_single_content")
.text("top")
.v_align("start")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.text("center")
.v_align("center")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.height(0.0)
.text("stretch")
.v_align("stretch")
.build(ctx),
)
.child(
Button::new()
.style("button_single_content")
.text("bottom")
.v_align("end")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::new()
.title("OrbTk - stack example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.resizable(true)
.child(MainView::new().margin(4.0).build(ctx))
.build(ctx)
})
.run();
}