pub fn hstack<VT: ViewTuple + 'static>(children: VT) -> impl ViewExpand description
Horizontal stack of up to 128 Views in a tuple. Each item can be a different view type.
Examples found in repository?
examples/gallery.rs (lines 4-7)
3fn button_example() -> impl View {
4 hstack((
5 caption("button"),
6 button("press me", |_| println!("pressed")),
7 ))
8}
9
10fn slider_example() -> impl View {
11 hstack((caption("slider"), state(|| 0.5, |s, _| hslider(s))))
12}
13
14fn caption(s: &'static str) -> impl View {
15 s.font_size(12).padding(Auto)
16}
17
18fn knob_example() -> impl View {
19 hstack((
20 caption("knob"),
21 state(|| 0.5, |s, _| knob(s).size([30.0, 30.0]).padding(Auto)),
22 ))
23}
24
25fn toggle_example() -> impl View {
26 hstack((
27 caption("toggle"),
28 state(|| false, |s, _| toggle(s).size([30.0, 30.0]).padding(Auto)),
29 ))
30}
31
32fn text_editor_example() -> impl View {
33 hstack((
34 caption("text_editor"),
35 state(
36 || "edit me".to_string(),
37 |txt, _| text_editor(txt).padding(Auto),
38 ),
39 ))
40}More examples
examples/nested.rs (lines 11-23)
10fn main() {
11 rui(hstack((
12 my_rectangle(),
13 vstack((
14 my_rectangle(),
15 hstack((
16 my_rectangle(),
17 vstack((
18 my_rectangle(),
19 hstack((my_rectangle(), vstack((my_rectangle(), my_rectangle())))),
20 )),
21 )),
22 )),
23 )));
24}examples/todo_list.rs (lines 5-13)
3fn add_button(todos: impl Binding<Vec<String>>) -> impl View {
4 state(String::new, move |name, _| {
5 hstack((
6 text_editor(name),
7 button(text("Add Item"), move |cx| {
8 let name_str = cx[name].clone();
9 todos.with_mut(cx, |todos| todos.push(name_str));
10 // Gotta fix a bug in text_editor!
11 // cx[name] = String::new();
12 }),
13 ))
14 })
15}Additional examples can be found in: