SLGuiIcon.sleela
lib/gui/version-military/SLGuiIcon.sleela · 150 line(s) · sleela
<< lib/gui/version-military/SLGuiIcon.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLGuiIcon — a carefully sized, precisely placed icon that
can be attached to a button, a menu item, or any clickable component. It
carries an asset name, a size TIER (a small set of calm, matched sizes so
icons read consistently across the UI rather than at arbitrary pixel
sizes), a POSITION relative to the label (leading / trailing / top / icon-
only), a gap between icon and label, a tint, and an optical-alignment nudge
so an icon sits visually centred (not just geometrically). The point is
aesthetic calm: every icon is one of a few matched sizes, placed perfectly
for the component it rides on.
Family: gui. Attached to a node (via SLGuiIconHost / effects) on buttons,
menu items, and clickables; the host paints the asset at the computed rect. >>
#sleela 2.5
material;
class SLGuiIcon {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 11232;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-16";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< Matched size tiers (px) — a calm, consistent scale, not arbitrary sizes. >
< 12 px (dense toolbars / inline) >
static final int SIZE_XS = 0;
< 16 px (menu items) >
static final int SIZE_SM = 1;
< 20 px (standard buttons) >
static final int SIZE_MD = 2;
< 28 px (primary actions) >
static final int SIZE_LG = 3;
< 40 px (feature tiles) >
static final int SIZE_XL = 4;
< Placement of the icon relative to the component's label. >
< before the label (default LTR) >
static final int POS_LEADING = 0;
< after the label >
static final int POS_TRAILING = 1;
< above the label (stacked) >
static final int POS_TOP = 2;
< icon only, no label >
static final int POS_ONLY = 3;
< host-resolvable icon name/path >
String asset;
< SIZE_* >
int sizeTier;
< POS_* >
int position;
< gap between icon and label, 0..24 >
int gapPx;
< color tint ("accent"/"#rrggbb"/"" = asset's own color) >
String tint;
< horizontal optical-centering nudge, -6..6 px >
int opticalDx;
< vertical optical-centering nudge, -6..6 px >
int opticalDy;
void configure(String iconAsset) {
asset = (iconAsset == null) ? "" : iconAsset;
sizeTier = SIZE_MD; position = POS_LEADING; gapPx = 8;
tint = ""; opticalDx = 0; opticalDy = 0;
}
int clamp(int v, int lo, int hi) { if (v < lo) { return lo; } if (v > hi) { return hi; } return v; }
void setSizeTier(int t) { if (t >= SIZE_XS && t <= SIZE_XL) { sizeTier = t; } }
void setPosition(int p) { if (p >= POS_LEADING && p <= POS_ONLY) { position = p; } }
void setGapPx(int px) { gapPx = clamp(px, 0, 24); }
void setTint(String color) { tint = (color == null) ? "" : color; }
< Nudge the icon a few px for true optical centering (not just geometric). >
void setOpticalNudge(int dx, int dy) { opticalDx = clamp(dx, -6, 6); opticalDy = clamp(dy, -6, 6); }
< The matched pixel size for the tier. >
int sizePx() {
if (sizeTier == SIZE_XS) { return 12; }
if (sizeTier == SIZE_SM) { return 16; }
if (sizeTier == SIZE_LG) { return 28; }
if (sizeTier == SIZE_XL) { return 40; }
< SIZE_MD >
return 20;
}
String asset_() { return asset; }
boolean hasAsset() { return asset != ""; }
int getSizeTier() { return sizeTier; }
int getPosition() { return position; }
int getGapPx() { return gapPx; }
String getTint() { return tint; }
boolean iconOnly() { return position == POS_ONLY; }
String positionName() {
if (position == POS_TRAILING) { return "trailing"; }
if (position == POS_TOP) { return "top"; }
if (position == POS_ONLY) { return "icon-only"; }
return "leading";
}
String sizeName() {
if (sizeTier == SIZE_XS) { return "xs/12"; }
if (sizeTier == SIZE_SM) { return "sm/16"; }
if (sizeTier == SIZE_LG) { return "lg/28"; }
if (sizeTier == SIZE_XL) { return "xl/40"; }
return "md/20";
}
< Serialize to a node style descriptor the reconciler applies ("icon:..."). >
String toStyle() {
return "icon:" + asset + "/" + sizePx() + "/" + positionName() + "/gap" + gapPx +
(tint != "" ? "/tint" + tint : "") +
(opticalDx != 0 || opticalDy != 0 ? "/nudge" + opticalDx + "," + opticalDy : "") + ";";
}
boolean valid() { return asset != "" && gapPx >= 0 && gapPx <= 24; }
}