Home /Modules/docs/UI-COMPONENT-QUALITY.md

UI-COMPONENT-QUALITY.md

docs/UI-COMPONENT-QUALITY.md · 93 line(s) · markdown

UI component quality — visibility, margin, and icon

Author: Kiro Agent · SLeeLa project · 2026 Status: Shipped. The classes described here are in lib/ui (#sleela 2.5), check and run with the source-built compiler, and are covered by the runnable self-check lib/ui/verify-pixel-perfect.sleela (47 assertions, all passing). Every native call named below exists in the ui* bridge (impl/core/sleela_ui_ids.h); no capability is invented.


Summary

In the lib/ui standard layout model a component is fully described by quality + size + placement:

SLComponentQuality now carries six faithfully-realizable quality axes. The original three were role, emphasis, and interactivity; this edition adds visibility, margin, and icon. Each axis maps 1:1 to a real ui* bridge call, so the number of quality aspects the standard model can deliver to the native toolkit grows without inventing any toolkit capability.


The quality axes

AxisSLComponentQuality APIRealized by SLLayoutDriver via
roleasBody() / asSurface() / asChrome() / asAccent(), getRole()window theme (the toolkit has no per-widget surface call, so role is a themed-renderer hint)
emphasisnormal() / primary() / danger(), isPrimary() / isDanger()uiWidgetSuggested, uiWidgetDestructive
interactivityenable() / disable() / setInteractive(on), isInteractive()uiWidgetSensitive
visibilityshow() / hide() / setVisible(on), isVisible()uiWidgetVisible
marginmargin(px) / setMargins(top, right, bottom, left), getMargin*(), hasMargin()uiWidgetMargin
iconicon(symbol) / iconFromAsset(path) / clearIcon(), getIconSymbol() / getIconAsset(), hasIcon()uiWidgetSetIcon

Defaults for a freshly added component: body / normal / enabled / shown, no margin, no icon. Negative margins are clamped to 0.

describe() reports the whole quality in one line, e.g.:

quality:accent/primary/enabled/shown/margin[4,6,4,0]/icon(save)

Example

SLLayoutFrame f = new SLLayoutFrame(); f.create();
f.useColumn(8, 12);
f.add("title", 40);
f.add("list", 0);          < flexible: fills the rest >
f.add("save", 36);
f.place(0, 0, 320, 600);

f.qualityOf("title").asChrome();
f.qualityOf("list").asSurface(); f.qualityOf("list").margin(8);
f.qualityOf("save").asAccent(); f.qualityOf("save").primary();
f.qualityOf("save").icon("save");

< realize onto native widgets >
SLLayoutDriver d = new SLLayoutDriver(); d.create();
int box = d.realize(root, f);
int save = uiButton(box, "Save");
d.applyNamed(f, "save", save);   < size + suggested + icon applied >

When realized, SLLayoutDriver.applyQuality applies every honorable part: primary → uiWidgetSuggested, danger → uiWidgetDestructive, disable() → uiWidgetSensitive, hide() → uiWidgetVisible, a margin → uiWidgetMargin, and an icon → uiWidgetSetIcon. The role is honored through the window theme.


References