<< lib/user-interface/SLGuiWidgetFactory.sleela SLeeLa Standard Library Definition. Definition: Defines SLGuiWidgetFactory — the single place that knows how a DOM tag maps to a real SleelaUI widget. Given a node's tag and a parent widget handle it calls the matching `ui*` built-in (uiBox / uiButton / uiLabel / uiEntry / uiToggle / uiHeaderBar / uiStatusBar / ...) and returns the new widget handle, so the reconciler (SLGuiMount) never hard-codes toolkit knowledge. Tags mirror the SleelaUI vocabulary; an unknown tag falls back to a vertical box so an unrecognised element still has a container to hold children. This is the DOM->toolkit construction seam. Family: user-interface. The factory crosses the `ui*` SLVM bridge to the real toolkit; SLeeLa still owns the node that the widget mirrors. >> #sleela 2.5 material; class SLGuiWidgetFactory { < ---- 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 = 11052; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-13"; < 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; } < Orientation ordinals (mirror SLUIOrientation / SLWidget). > static final int ORIENT_VERTICAL = 0; static final int ORIENT_HORIZONTAL = 1; < Construct the widget for `node` inside `parentHandle`. Returns the new > < widget handle, or -1 when it could not be created. `label` is the node's > < initial text/placeholder (empty string when it has none). > int construct(int parentHandle, String tag, String label) { if (parentHandle < 0) { return -1; } < Containers. > if (tag == "window" || tag == "box" || tag == "vbox") { return uiBox(parentHandle, ORIENT_VERTICAL, 8); } if (tag == "hbox" || tag == "row") { return uiBox(parentHandle, ORIENT_HORIZONTAL, 8); } if (tag == "header" || tag == "headerbar") { return uiHeaderBar(parentHandle); } if (tag == "status" || tag == "statusbar") { return uiStatusBar(parentHandle); } if (tag == "frame" || tag == "group") { return uiFrame(parentHandle, label); } < Leaf / interactive controls. > if (tag == "label" || tag == "text") { return uiLabel(parentHandle, label); } if (tag == "button") { return uiButton(parentHandle, label); } if (tag == "entry" || tag == "input") { return uiEntry(parentHandle, label); } if (tag == "toggle" || tag == "switch") { return uiToggle(parentHandle, label, 0); } if (tag == "spacer") { return uiSpacer(parentHandle); } if (tag == "separator" || tag == "hr") { return uiSeparator(parentHandle, ORIENT_HORIZONTAL); } < Unknown tag: give it a vertical box so children still have a container. > return uiBox(parentHandle, ORIENT_VERTICAL, 8); } < Is this tag an interactive control the host should poll for activations? > boolean interactive(String tag) { return tag == "button" || tag == "entry" || tag == "input" || tag == "toggle" || tag == "switch"; } < Which SLGuiEventType an activation on this tag should raise. > < Buttons -> CLICK; entries -> SUBMIT (Enter); toggles -> TOGGLE. > int activationEvent(String tag) { if (tag == "button") { return SLGuiEventType.CLICK; } if (tag == "toggle" || tag == "switch") { return SLGuiEventType.TOGGLE; } if (tag == "entry" || tag == "input") { return SLGuiEventType.SUBMIT; } return SLGuiEventType.CUSTOM; } boolean isContainer(String tag) { return tag == "window" || tag == "box" || tag == "vbox" || tag == "hbox" || tag == "row" || tag == "header" || tag == "headerbar" || tag == "status" || tag == "statusbar" || tag == "frame" || tag == "group"; } }