|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
| Module | Includes |
|---|---|
| style | Plain snapshots, schema access, extension classes, schemes and palette data. No codec. |
| style_kdl | KDL read/write, the only style module requiring ckdl. |
| style_json | Allocation-free strict RFC 8259 front end over the same schema. |
| Attribute | Rule |
|---|---|
| Address | Use section/leaf pairs or section.leaf. Walks visit each row once; the extension walk also visits registered properties and overlays. |
| Value | Typed reads and writes preserve token references. Unknown, incompatible or out-of-range values refuse; they are not clamped. |
| Decode | Caller sets a byte budget (0 uses RMGUI_STYLE_DEFAULT_MAX_BYTES) and diagnostic storage. Refusal leaves outputs unchanged. |
Style JSON is an object with "schema":3, optional "scheme":"nord", "spacing":{...}, "font-size-delta":{...}, "colors":{...}, "templates":{"button":{...},...} and "desktop":{...}. Leaves use the schema's dashed names: integers, [red,green,blue,alpha] byte arrays, text-style/spring names, or token strings such as "$spacing.md" and "$colors.accent". Omitted fields inherit the builtin snapshot; unknown or duplicate keys, malformed UTF-8/Unicode, trailing input and invalid values are errors with line/column diagnostics. KDL retains its canonical schema-3 spelling and accepts schema-2 input.
Runtime classes borrow caller descriptor names and enum tables, and store copied properties/overlays in caller-sized arrays. Builtin class IDs remain 0..RMGUI_STYLE_CLASS_COUNT-1; extension IDs start at RMGUI_STYLE_CLASS_COUNT, in registration order. Resolution writes a caller-sized typed property table. Lengths scale with UI scale; integers and enums do not. Precedence is base, HOVER, PRESSED, FOCUSED, DISABLED, SELECTED, DEFAULT, INACTIVE, with later authored overlays winning independently. Register descriptors before decoding values. KDL authors class "badge" { count 7; state hover { count 8; } }; JSON authors "classes":{"badge":{"values":{"count":7},"states":{"hover":{"count":8}}}}. Extension decoding takes a disjoint caller-owned scratch registry to preserve transactional failure, including allocation failure inside the KDL reader.
<rmgui/recipe.h> describes paint as borrowed C tables, independent of a text codec. rmgui_recipe_paint_to evaluates ordered layers into CPU or RECORD targets without allocation. Layers provide independently rounded fills, rounded strokes, exterior shadow/glow, linear/radial/conic gradients, filtered images, nearest nine-patch/tile fills (multiply, luminance ramp or three-stop bevel tint), general Q16 contours, and text ink selection. Layer state masks select required and excluded flags. Insets and radii run clockwise from top and top-left respectively. Literal metrics scale from logical pixels; property references read already-resolved COLOR or LENGTH/INT properties by class-local ID. Gradient endpoints are Q16 fractions of the inset bounds; radial radii are fractions of its extent. Contours use absolute device Q16 vertices and caller-sized crossing storage. There is no recipe, part or layer count limit beyond caller storage and primitive contracts. Contours accept caller-preflattened path fills or stroke outlines; recipes borrow the resulting vertices rather than retaining a path builder or allocating flattening storage. Equal-radius OVER fills with a nonempty inset rectangle and a shorter side of at most 65535 device pixels use native-supported rounded-stroke commands with identical CPU sample coverage. Other fills retain the per-corner fill command; native replay may refuse that opcode.
Register a class with rmgui_style_ext_register, bind its borrowed rmgui_recipe_set_t with rmgui_style_ext_bind_recipes, then use rmgui_style_resolve_recipes to combine a builtin geometry template with its own properties and faces. Part mappings use the skin target/part vocabulary; the most specific state subset wins, with declaration order breaking ties. A zero-state entry is the fallback. A matching recipe takes precedence over bound skin art in library painters, including boxes, buttons, fields and list rows; no unbound-style workaround is needed. Missing parts retain normal skin/fallback behavior. An INK layer selects the label ink. For contour faces, assign caller-owned intersections to resolved.recipe_scratch; other faces need no scratch. Property storage, binding tables and source images remain borrowed and must outlive resolved styles. Record commands snapshot scalar, gradient and contour values, but image headers/pixels stay immutable through submit/discard. CPU sources must not overlap the destination. The evaluator checks every active layer against an empty destination before painting: invalid inputs leave pixels and optional ink unchanged. Bounded RECORD exhaustion poisons the stream, preventing prefix replay. Only active image layers impose the CPU source nonaliasing constraint. An INK layer changes the returned ink or a library element's label colour; it does not emit text itself.
Recipes are runtime data, not callbacks or a closed skin enum. Existing KDL/JSON extension property codecs can edit their parameters; recipe graph storage and asset ownership remain host responsibilities. Registry copies preserve borrowed recipe bindings. The optional recipe module does not depend on codecs, builtin skins, or the path builder.
rmgui_skin_recipe exposes a selected skin part as a caller-owned image recipe layer, including its source, tier ratio, tint, nine-patch geometry and tile phase. All six builtin skins use this same image-recipe model; their sprite cache is an equivalent optimized evaluation. The source sheets remain generated artwork rather than being rerasterized with different coverage rules: flat-hairline uses its own coverage/alpha thresholds; bevel-classic and pixel-retro use pixel-owned glyphs and edges; remix uses scheme-derived material grain; Lion uses capsule/material silhouettes; Experience uses its native-tier artwork and semantic caption/progress colours. Replacing those source pixels with the general AA shape primitives would change the established images. Their part/state mapping, tint and stretch/tile structure are recipe data; their source-art generators are retained for byte identity. The Recipes showcase edits a registered quest card, compares CPU and RECORD pixels, and reproduces each builtin skin from its exposed recipe with a differing-pixel readout.
Gruvbox, Nord, Dracula and the other builtin schemes are example palette data, not a closed authoring model. A caller-owned palette defines sixteen Base16 slots, eleven optional role overrides and syntax colours; C can apply it directly, and KDL/JSON can encode and decode it without recompilation. JSON palettes use {"schema":3,"palette":{"base00":[0,0,0,255],...}, "roles":{...},"syntax":{...}}; all sixteen slots are required. With a caller palette, "$base00" and "$role.accent" preserve palette bindings. The Style config showcase edits the same sheet through both front ends and paints a runtime-defined badge. Its decode-budget control switches between the caller pane capacity and 64 bytes; a refused Apply retains the live style.
<rmgui/style_palette.h> needs no codec. Built-in selection and rmgui_style_palette_builtin read the same role and syntax examples; the default example takes its roles from rmgui_style_builtin(). Copies are independent, and all roles and non-plain syntax overlays are masked in. Use role references to apply edited role data rather than Base16 slots.
Pass an initialized valid declaration, for example a copy of *rmgui_style_builtin(). Applying preserves class rows and token references, sets scheme metadata to DEFAULT and leaves the snapshot unchanged on refusal. Use rmgui_style_palette_syntax for the edited copy's syntax, including plain text. The Authored examples showcase cycles schemes and edits a copied accent and background without changing the surrounding sheet or built-in data.