rsx
proc macro · ferroui-view-macros · v0.5.0
bang macro rsx!
An element tree, expanded to the builders of ferroui-view.
rsx! {
StackPanel { spacing: 8.0,
TextBlock { text: move || format!("Count: {}", count.get()) }
Button { on_click: move |_| count.update(|c| *c += 1), "Increment" }
}
}
Name { ... }is an element of the control class or componentNamein scope (<Name as Builder>::builder()):StackPanelisstack_panel(),todo::Rowthe componentRowof the moduletodo.namealone gives the setternamethe variablename, as a field of a struct is given (TextBlock { text }).name: valuecalls the setter.name(value): a property (spacing: 8.0), a handler (on_click: ...),key,name,class.Owner.name: valuesets an attached property:Grid.row: 1calls.grid_row(1).name(a, b)calls a method of the builder with several arguments:on_changed(TextBox::text_property(), handler),set(Grid::row_property(), 1)(the indexercontrol[Property] = 1upstream),bind(TextBlock::text_property(), binding)."text"is a text child,{expr}any child (an element, a builder, a list,for_each(..),show(..)), and a nested element a child.if cond { .. } else { .. }andfor x in items { .. }choose and repeat children when the tree is built (for children that follow state, use{for_each(..)},{show(..)}or{dynamic(..)}).
Several nodes at the root make a fragment.
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.