Expand description
Custom components — a mod’s own reusable widgets, used from .yui
markup like the built-in elements (the user controls of WPF).
A component is a .yui file with a <Component> root: its properties
and events declared in markup, its body bound to them with
{x:Bind ...}, and an optional code-behind .rs for methods the
bindings call (see Yog-IDLE’s docs/yui.md, “Components”):
<Component name="StatBar" description="A labelled progress bar." icon="item:experience_bottle"
design_w="120" design_h="10">
<Property name="label" type="text" default="HP"/>
<Property name="value" type="number" default="0.5" doc="Filled fraction, 0..1" category="Data"/>
<Row w="100%" gap="4">
<Label text="{x:Bind label}"/>
<Spacer w="{x:Bind bar_w()}" h="6" bg="#FF55FF55"/>
</Row>
</Component>yog build generates the Component implementation from it (a struct
with one typed field per property, NAME, the designer metadata, PROPS,
build) and
registers it (yog_api::ui_component!) — this module is that code’s
runtime: the registry, Props (the instance’s attribute values, read
back typed), bind (binding conversions) and designer, Yog-IDLE’s
door into a mod built for the host machine.
A screen uses a component like any element:
<StatBar x="8" y="8" w="120" label="Mana" value="0.3"/> becomes
component::build("StatBar", &[("label", "Mana"), ("value", "0.3")])
followed by the builder calls for the common attributes (x, y, w,
h, bg, on_click, …).
Modules§
- bind
- Conversions of
{x:Bind ...}values to what a bound attribute takes (generated component code calls these). - designer
- The screen designer’s protocol (see the module docs): one C-ABI
entry point,
yog_ui_designer, taking a text request and answering through a write callback.
Structs§
- Component
Spec - A registered component (see
register). - Prop
- One property of a component.
- Props
- A component’s property values: what the element set, else the defaults.
Enums§
- Prop
Kind - A property’s type: how
.yuiwrites it and how the designer edits it.
Constants§
- COMMON_
ATTRS - The attributes every
.yuielement takes (yog buildapplies them to a component’s widget with builder calls — they never reach itsProps).
Traits§
- Component
- A custom component — implemented by the code
yog buildgenerates from a<Component>.yui(see the module docs).
Functions§
- apply_
style - One common style attribute applied to
was generated code would (layout attributes — position, size, dock, flex — are left to the caller; malformed values are ignored). - build
- The component
namebuilt from.yuiattribute values (what generated screen code calls). An unknown name gives a red error box rather than a panic, so a screen with a typo still opens. - components
- Every registered component, in registration order.
- error_
box - What
buildshows for a component it can’t build. - find
- The registered component
name. - parse_
color #RRGGBB,#AARRGGBBor0xAARRGGBB(as.yuicolors), or a decimal0xAARRGGBBvalue (what a boundu32property arrives as).- register
- Adds
Cto this library’s components (a later registration of the same name replaces the earlier one).yog_api::ui_component!calls this when the mod’s library loads. - register_
spec