pub fn hstack<VT: ViewTuple + 'static>(children: VT) -> impl View
Expand 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)
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
fn button_example() -> impl View {
hstack((
caption("button"),
button("press me", |_| println!("pressed")),
))
}
fn slider_example() -> impl View {
hstack((caption("slider"), state(|| 0.5, |s, _| hslider(s))))
}
fn caption(s: &'static str) -> impl View {
s.font_size(12).padding(Auto)
}
fn knob_example() -> impl View {
hstack((
caption("knob"),
state(|| 0.5, |s, _| knob(s).size([30.0, 30.0]).padding(Auto)),
))
}
fn toggle_example() -> impl View {
hstack((
caption("toggle"),
state(|| false, |s, _| toggle(s).size([30.0, 30.0]).padding(Auto)),
))
}
fn text_editor_example() -> impl View {
hstack((
caption("text_editor"),
state(
|| "edit me".to_string(),
|txt, _| text_editor(txt).padding(Auto),
),
))
}
More examples
examples/nested.rs (lines 11-23)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
fn main() {
rui(hstack((
my_rectangle(),
vstack((
my_rectangle(),
hstack((
my_rectangle(),
vstack((
my_rectangle(),
hstack((my_rectangle(), vstack((my_rectangle(), my_rectangle())))),
)),
)),
)),
)));
}
examples/todo_list.rs (lines 5-13)
3 4 5 6 7 8 9 10 11 12 13 14 15
fn add_button(todos: impl Binding<Vec<String>>) -> impl View {
state(String::new, move |name, _| {
hstack((
text_editor(name),
button(text("Add Item"), move |cx| {
let name_str = cx[name].clone();
todos.with_mut(cx, |todos| todos.push(name_str));
// Gotta fix a bug in text_editor!
// cx[name] = String::new();
}),
))
})
}
Additional examples can be found in: