pub struct VStack { /* private fields */ }Expand description
Container that positions children vertically.
Accepts any Widget from rlvgl_widgets and arranges them
top-to-bottom.
Implementations§
Source§impl VStack
impl VStack
Sourcepub fn new(width: i32) -> Self
pub fn new(width: i32) -> Self
Create an empty vertical stack with the given width.
Examples found in repository?
examples/demo.rs (line 61)
13fn main() {
14 let theme = Theme::material_light();
15 let style = StyleBuilder::new()
16 .bg(theme.tokens.colors.primary)
17 .radius(theme.tokens.radii.md)
18 .build();
19
20 let layout = {
21 #[cfg(feature = "view")]
22 {
23 view! { VStack::new(90)
24 .child(20, |rect| Heading::new("Demo", rect))
25 .child(20, |rect| Text::new("Hello", rect))
26 .child(30, |rect| {
27 Button::new("Tap", rect)
28 .icon("save")
29 .on_click(|_| println!("clicked"))
30 })
31 .child(30, |rect| {
32 IconButton::new("edit", rect)
33 .on_click(|_| println!("edit"))
34 })
35 .child(20, |rect| {
36 Checkbox::new("Accept", rect).on_change(|v| println!("checkbox: {v}"))
37 })
38 .child(20, |rect| {
39 Switch::new(rect).on_change(|v| println!("switch: {v}"))
40 })
41 .child(20, |rect| {
42 Radio::new("Option", rect).on_change(|v| println!("radio: {v}"))
43 })
44 .child(20, |rect| { Badge::new("NEW", rect) })
45 .child(20, |rect| {
46 Tag::new("rust", rect).on_remove(|| println!("tag removed"))
47 })
48 .child(30, |rect| { Alert::new("Saved", rect) })
49 .child(20, |rect| {
50 Input::new("Name", rect).on_change(|v| println!("input: {v}"))
51 })
52 .child(40, |rect| {
53 Textarea::new("Multiline", rect).on_change(|v| println!("textarea: {v}"))
54 })
55 .child(30, |rect| Modal::new("Modal", rect))
56 .child(30, |rect| Drawer::new("Menu", rect))
57 .child(30, |rect| Toast::new("Saved", rect)) }
58 }
59 #[cfg(not(feature = "view"))]
60 {
61 VStack::new(90)
62 .child(20, |rect| Heading::new("Demo", rect))
63 .child(20, |rect| Text::new("Hello", rect))
64 .child(30, |rect| {
65 Button::new("Tap", rect)
66 .icon("save")
67 .on_click(|_| println!("clicked"))
68 })
69 .child(30, |rect| {
70 IconButton::new("edit", rect).on_click(|_| println!("edit"))
71 })
72 .child(20, |rect| {
73 Checkbox::new("Accept", rect).on_change(|v| println!("checkbox: {v}"))
74 })
75 .child(20, |rect| {
76 Switch::new(rect).on_change(|v| println!("switch: {v}"))
77 })
78 .child(20, |rect| {
79 Radio::new("Option", rect).on_change(|v| println!("radio: {v}"))
80 })
81 .child(20, |rect| Badge::new("NEW", rect))
82 .child(20, |rect| {
83 Tag::new("rust", rect).on_remove(|| println!("tag removed"))
84 })
85 .child(30, |rect| Alert::new("Saved", rect))
86 .child(20, |rect| {
87 Input::new("Name", rect).on_change(|v| println!("input: {v}"))
88 })
89 .child(40, |rect| {
90 Textarea::new("Multiline", rect).on_change(|v| println!("textarea: {v}"))
91 })
92 .child(30, |rect| Modal::new("Modal", rect))
93 .child(30, |rect| Drawer::new("Menu", rect))
94 .child(30, |rect| Toast::new("Saved", rect))
95 }
96 };
97
98 let _ = (style, layout);
99}Sourcepub fn child<W, F>(self, height: i32, builder: F) -> Self
pub fn child<W, F>(self, height: i32, builder: F) -> Self
Add a child of the given height, created by the supplied builder.
Examples found in repository?
examples/demo.rs (line 62)
13fn main() {
14 let theme = Theme::material_light();
15 let style = StyleBuilder::new()
16 .bg(theme.tokens.colors.primary)
17 .radius(theme.tokens.radii.md)
18 .build();
19
20 let layout = {
21 #[cfg(feature = "view")]
22 {
23 view! { VStack::new(90)
24 .child(20, |rect| Heading::new("Demo", rect))
25 .child(20, |rect| Text::new("Hello", rect))
26 .child(30, |rect| {
27 Button::new("Tap", rect)
28 .icon("save")
29 .on_click(|_| println!("clicked"))
30 })
31 .child(30, |rect| {
32 IconButton::new("edit", rect)
33 .on_click(|_| println!("edit"))
34 })
35 .child(20, |rect| {
36 Checkbox::new("Accept", rect).on_change(|v| println!("checkbox: {v}"))
37 })
38 .child(20, |rect| {
39 Switch::new(rect).on_change(|v| println!("switch: {v}"))
40 })
41 .child(20, |rect| {
42 Radio::new("Option", rect).on_change(|v| println!("radio: {v}"))
43 })
44 .child(20, |rect| { Badge::new("NEW", rect) })
45 .child(20, |rect| {
46 Tag::new("rust", rect).on_remove(|| println!("tag removed"))
47 })
48 .child(30, |rect| { Alert::new("Saved", rect) })
49 .child(20, |rect| {
50 Input::new("Name", rect).on_change(|v| println!("input: {v}"))
51 })
52 .child(40, |rect| {
53 Textarea::new("Multiline", rect).on_change(|v| println!("textarea: {v}"))
54 })
55 .child(30, |rect| Modal::new("Modal", rect))
56 .child(30, |rect| Drawer::new("Menu", rect))
57 .child(30, |rect| Toast::new("Saved", rect)) }
58 }
59 #[cfg(not(feature = "view"))]
60 {
61 VStack::new(90)
62 .child(20, |rect| Heading::new("Demo", rect))
63 .child(20, |rect| Text::new("Hello", rect))
64 .child(30, |rect| {
65 Button::new("Tap", rect)
66 .icon("save")
67 .on_click(|_| println!("clicked"))
68 })
69 .child(30, |rect| {
70 IconButton::new("edit", rect).on_click(|_| println!("edit"))
71 })
72 .child(20, |rect| {
73 Checkbox::new("Accept", rect).on_change(|v| println!("checkbox: {v}"))
74 })
75 .child(20, |rect| {
76 Switch::new(rect).on_change(|v| println!("switch: {v}"))
77 })
78 .child(20, |rect| {
79 Radio::new("Option", rect).on_change(|v| println!("radio: {v}"))
80 })
81 .child(20, |rect| Badge::new("NEW", rect))
82 .child(20, |rect| {
83 Tag::new("rust", rect).on_remove(|| println!("tag removed"))
84 })
85 .child(30, |rect| Alert::new("Saved", rect))
86 .child(20, |rect| {
87 Input::new("Name", rect).on_change(|v| println!("input: {v}"))
88 })
89 .child(40, |rect| {
90 Textarea::new("Multiline", rect).on_change(|v| println!("textarea: {v}"))
91 })
92 .child(30, |rect| Modal::new("Modal", rect))
93 .child(30, |rect| Drawer::new("Menu", rect))
94 .child(30, |rect| Toast::new("Saved", rect))
95 }
96 };
97
98 let _ = (style, layout);
99}Trait Implementations§
Auto Trait Implementations§
impl Freeze for VStack
impl !RefUnwindSafe for VStack
impl !Send for VStack
impl !Sync for VStack
impl Unpin for VStack
impl UnsafeUnpin for VStack
impl !UnwindSafe for VStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more