Expand description
Component .yui files: a <Component> root declaring properties and
events, with one body element bound to them through {x:Bind ...} (the
same bindings as view-model screens, [crate::yui_vm::compile_bind]).
Generates a struct with one typed field per property and its
yog_api::ui::component::Component implementation, registered with
ui_component!. See Yog-IDLE’s docs/yui.md, “Components”.
<Component name=yog_ids::yui::STAT_BAR description="A labelled bar." icon="item:experience_bottle"
design_w="120" design_h="10">
<Property name="label" type="text" default="HP" doc="Shown on the left" category="Text"/>
<Property name="value" type="number" default="0.5"/>
<Event name="on_select"/>
<Row w="100%" gap="4">
<Label text="{x:Bind label}"/>
<Spacer w="{x:Bind bar_w()}" h="6" bg="#FF55FF55"/>
</Row>
</Component>Bindings are evaluated once per instance, when the screen’s tree is
built. Methods they call (bar_w()) live in the optional code-behind
stat_bar.rs (yog_api::ui_include!("stat_bar"); impl StatBar { ... });
components without one are compiled in by yog_api::ui_components!().
The root’s designer metadata — display_name, description, icon,
category, design_w/design_h, toolbox — goes into the
implementation’s constants as written (@Set.key references included),
for Yog-IDLE’s designer host.
Constants§
- INDEX_
FILE - Index of the components without a code-behind, included by
ui_components!().
Functions§
- generate
- The
.g.rssource of a<Component>.yui(name: its path undersrc/without the extension, as for screens). - write_
index - Writes
INDEX_FILE: a module per component.yuiundersrc/that has no code-behind.rsnext to it (thoseui_include!themselves). Warns when there are such components butsrc/lib.rsdoesn’t callyog_api::ui_components!().