Skip to main content

Module yui_component

Module yui_component 

Source
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="StatBar" 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.rs source of a <Component> .yui (name: its path under src/ without the extension, as for screens).
write_index
Writes INDEX_FILE: a module per component .yui under src/ that has no code-behind .rs next to it (those ui_include! themselves). Warns when there are such components but src/lib.rs doesn’t call yog_api::ui_components!().