Expand description
ferroui-view
A declarative way to write FerroUI user interfaces in Rust, without XAML:
elements built with chained setters (button().content("Add").on_click(..))
or with the rsx! macro, state held in signals that the properties of
controls follow, and children that follow state.
The pieces (docs/declarative-ui.md has the design):
Element: a description of controls, their property values, handlers and children. It is data, compared by value, so that a later reconciler can compare two trees and patch controls; mounting makes the controls (Element::mount).- Builders: a function per control class (
button(),stack_panel()) and a trait per class with a setter per property and a handler per routed event, generated from the sources (scripts/generate_view_builders.py). - Reactivity:
Signal,Memo,effect, owned by anOwner. A setter given a signal or a closure makes the property follow it. - Children that follow state:
for_each(keyed),show,dynamic. - With the feature
desktop: [launch] runs an application whose main window is an element.
ⓘ
use ferroui_view::prelude::*;
fn counter() -> Element {
let count = signal(0);
stack_panel()
.spacing(8.0)
.child(text_block().text(move || format!("Count: {}", count.get())))
.child(button().content("Increment").on_click(move |_| count.update(|c| *c += 1)))
.into()
}Re-exports§
pub use builder::Bind;pub use builder::Builder;pub use builder::El;pub use builder::ElementBuilder;pub use builder::FromValue;pub use builder::IntoProp;pub use builder::IntoValue;pub use builder::TypedProperty;pub use builder::ViewClass;pub use element::Element;pub use element::IntoChild;pub use element::IntoChildren;pub use element::IntoElement;pub use element::Key;pub use reactive::batch;pub use reactive::effect;pub use reactive::memo;pub use reactive::on_cleanup;pub use reactive::signal;pub use reactive::untrack;pub use reactive::Memo;pub use reactive::Owner;pub use reactive::Signal;pub use reactive::TwoWay;
Modules§
- builder
- The builders of elements:
El, the element of a control class, its methods, and the conversions of what a setter takes (IntoProp). - element
- The element tree: a description of controls, their properties, handlers
and children, and how it becomes controls (
Element::mount). - generated
- The generated builders (see the module documentation).
- prelude
- Everything an application written with the builders or the macro uses.
- reactive
- Fine-grained reactivity: signals, memos, effects and the owners that dispose them.
Macros§
- rsx
- An element tree, expanded to the builders of
ferroui-view.
Structs§
- NodeRef
- The control an element made, once it is mounted (see
El::node_ref).Copy; reading it is reactive.
Traits§
- Grid
Definitions - The rows and columns of a grid, in the text form XAML takes
(
"Auto,*,2*,40").
Functions§
- dynamic
- Children computed by a reactive closure: made again whenever what it
read changes. An element with a key keeps its control while an element
with the same key comes back (its values are not compared: give the key
what identifies the values, or use
for_each). - for_
each - A list of children made from items, one per item, kept by key: an item
whose key and value stay keeps its control; an item that is new or whose
value changed gets a new one; the controls of items that left are taken
out.
eachis reactive: the list follows the signals it reads. - show
- The children of
thenwhilewhenis true, and nothing otherwise. The children are made again only when the condition changes. - show_
else - The children of
thenwhilewhenis true, those ofotherwiseotherwise.
Attribute Macros§
- component
- A component: a function whose parameters are its properties, with a
builder so that
rsx!and the builders use it like a control.