Macro oxygengine_user_interface::widget [−][src]
macro_rules! widget {
{ () } => { ... };
{ [] } => { ... };
({ { $expr : expr } }) => { ... };
({ $expr : expr }) => { ... };
{
($(# { $key : expr }) ? $(| { $idref : expr }) ? $type_id : path
$(: { $props : expr }) ? $(| { $shared_props : expr }) ?
$({ $($named_slot_name : ident = $named_slot_widget : tt) * }) ?
$(| [$listed_slot_widgets : expr] |) ? $([$($listed_slot_widget : tt) *])
?)
} => { ... };
(@ wrap { $expr : expr }) => { ... };
(@ wrap $tree : tt) => { ... };
}
Expand description
Create a WidgetNode
struct from a custom widget tree DSL
The widget
macro is primarily used to construct widget trees as the return value of
components.
Example
// You can create [`WidgetNode`]'s and assign them to variables
let popup_widget = widget! {
(popup: {popup_props})
};
widget! {
// parenthesis are used around components and they each _may_ have a key,
// props, shared props, listed children, and/or named children. Everything is,
// optional.
(#{"widget_key"} my_component: {my_component_props} | {my_component_shared_props} {
// named children
content = (component_1: {component_1_props})
} [
// listed children
(component_2: {component_2_props})
(component_3: {component_3_props})
// You can also use `{variable_name}` syntax to expand variables into a widget
{popup_widget}
])
}