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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//! # Floem built-in Views
//!
//! This module contains the basic built-in Views of Floem.
//!
//! ## Composing Views
//! The views in this module are the main building blocks for composing UIs in Floem.
//! There is a collection of different `stacks` and `lists` that can be used to build collections of Views.
//! There are also basic widgets such as [text_inputs](text_input::text_input), [labels](label::label), [images](img::img), and [svgs](svg::svg).
//!
//! ## Example: Counter
//! ```rust
//! use floem::{reactive::*, views::*};
//!
//! let mut counter = RwSignal::new(0);
//!
//! v_stack((
//! label(move || format!("Value: {counter}")),
//! h_stack((
//! button("Increment").action(move || counter += 1),
//! button("Decrement").action(move || counter -= 1),
//! )),
//! ));
//! ```
//! Views in Floem can also be easily refactored.
//! ## Example: Refactored Counter
//! ```rust
//! use floem::prelude::*;
//!
//! let mut counter = RwSignal::new(0);
//!
//! let counter_label = label(move || format!("Value: {counter}"));
//!
//! let increment_button = button("Increment").action(move || counter += 1);
//! let decrement_button = button("Decrement").action(move || counter -= 1);
//!
//! let button_stack = (increment_button, decrement_button).h_stack();
//!
//! (counter_label, button_stack).v_stack();
//! ```
//!
//!
//! ### Stacks and Lists
//! There are a few different stacks and lists that you can use to group your views and each is discussed here.
//!
//!
//! They are:
//! - basic [stack](stack())
//! - static and always contains the same elements in the same order
//! - [dynamic stack](dyn_stack())
//! - can dynamically change the elements in the stack by reactively updating the list of items provided
//! - [virtual stack](virtual_stack::virtual_stack())
//! - can dynamically change the elements in the stack
//! - can lazily load the items as they appear in a [scroll view](scroll())
//!
//! There is also a basic [list](list()) and a [virtual list](virtual_list::virtual_list()).
//! Lists are like their stack counterparts but they also have built-in support for the selection of items: up and down using arrow keys, top and bottom control using the home and end keys, and for the "acceptance" of an item using the Enter key.
//! You could build this manually yourself using stacks but it is common enough that it is built-in as a list.
//!
//! ## View Trait
//! The [View](crate::View) trait is the trait that Floem uses to build and display elements.
//! The trait contains the methods for implementing updates, styling, layout, events, and painting.
//!
//! Views are types that implement `View`.
//! Many of these types will also be built with a child that also implements `View`.
//! In this way, views can be composed together easily to create complex UIs.
//! This composition is the most common way to build UIs in Floem.
//!
//! Creating a type and manually implementing the View trait is typically only needed for building new widgets and for special cases.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use ;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;