53 void releaseSquirrelRoots() noexcept;
58 void shutdownBackend();
60 bool isBackendReady() const;
63 void processEvent(const SDL_Event *event);
65 void beginFrameAndRender();
67 void dispatchEvents();
70 bool wantCaptureMouse() const;
72 bool wantCaptureKeyboard() const;
121 bool select(const
std::
string &
name);
139 [[nodiscard]]
UIHostHandle findHostByOwner(uint32_t ownerId) const;
151 void bindOwner(uint32_t ownerId);
156 void beginWindow(
const std::string &
title,
const std::string &
id =
"root");
158 void beginGroup(
const std::string &
id =
"");
160 void beginList(
const std::string &
id);
162 void beginCollapsing(
const std::string &
label,
const std::string &
id =
"",
bool open =
true);
164 void beginChild(
const std::string &
id,
float width = 0.f,
float height = 120.f);
166 void beginCard(
const std::string &
id =
"");
168 bool beginNinePatch(
const std::string &
path,
const std::string &
id =
"",
171 void beginMenuBar(
const std::string &
id =
"");
173 void beginMenu(
const std::string &
label,
const std::string &
id =
"");
175 void beginToolbar(
const std::string &
id =
"");
177 void beginToolbox(
const std::string &
id =
"",
float cellSize = 0.f,
int columns = 0);
179 void beginSidebar(
const std::string &
id =
"",
float width = 0.f);
181 void beginStatusBar(
const std::string &
id =
"");
183 void beginSplitPane(
const std::string &
direction =
"row",
float ratio = 0.25f,
184 const std::string &
id =
"");
186 void beginTabBar(
const std::string &
id =
"");
191 void beginTabContainer(
const std::string &activePageId,
const std::string &
id =
"");
193 void beginPanelFrame(
const std::string &
title,
const std::string &
id =
"");
195 void beginDockArea(
const std::string &
region,
const std::string &
id =
"");
197 void beginAppFrame(
const std::string &
id =
"");
199 void addTab(
const std::string &
label,
const std::string &pageId,
bool selected =
false,
const std::string &
id =
"");
202 void beginScrollList(
const std::string &
id =
"",
float height = 0.f,
float itemHeight = 0.f);
209 void beginFlex(
const std::string &
direction =
"row",
const std::string &
id =
"",
212 void beginRow(
const std::string &
id =
"",
float gap = -1.f);
214 void beginColumn(
const std::string &
id =
"",
float gap = -1.f);
216 void beginGrid(
int columns,
const std::string &
id =
"",
float columnGap = -1.f,
217 float rowGap = -1.f);
221 void addText(
const std::string &content,
const std::string &
id =
"");
224 void addTextWrapped(
const std::string &content,
float width,
const std::string &
id =
"");
226 void addButton(
const std::string &
label,
const std::string &
id =
"");
228 void addIcon(
const std::string &
name,
const std::string &
id =
"");
230 void addIconButton(
const std::string &
name,
const std::string &
label =
"",
231 const std::string &
id =
"");
233 void addSameLine(
const std::string &
id =
"");
235 void addSeparator(
const std::string &
id =
"");
237 void addCheckbox(
const std::string &
label,
bool checked,
const std::string &
id =
"");
239 void addSlider(
const std::string &
label,
float value,
float minV,
float maxV,
240 const std::string &
id =
"");
245 void addColorPalette(
const std::string &
label,
float r,
float g,
float b,
float a = 1.f,
246 const std::string &
id =
"");
248 void addProgress(
float fraction,
const std::string &
id =
"",
const std::string &overlay =
"");
257 void addSkillSlot(
const std::string &
id,
float size, uint64_t iconTexture,
float cooldown,
const std::string &
key);
259 void setItemFillDirection(
const std::string &
direction,
bool stretch);
262 void setItemRadialFill(
float startDegrees,
bool clockwise,
float innerRadius);
265 void addImage(
const std::string &
id =
"",
float width = 0.f,
float height = 0.f);
267 bool addNinePatch(
const std::string &
path,
const std::string &
id =
"",
271 void addImageButton(
const std::string &
id,
float width,
float height);
274 void addViewport(
const std::string &
id,
float width = 0.f,
float height = 0.f);
278 const std::string &
id =
"");
280 void addLink(
const std::string &
label,
const std::string &
target,
const std::string &
id);
282 void setItemTextInput(
bool multiline,
bool readOnly,
const std::string &placeholder);
284 void setItemHelp(
const std::string &help,
const std::string &disabledReason);
286 void addInputText(
const std::string &
label,
const std::string &
value,
const std::string &
id =
"");
288 void addSearchField(
const std::string &hint,
const std::string &
value =
"",
289 const std::string &
id =
"");
291 void addSwitch(
const std::string &
label,
bool checked,
const std::string &
id =
"");
293 void addBadge(
const std::string &
label,
const std::string &
id =
"");
295 void addSectionHeader(
const std::string &
label,
const std::string &
id =
"");
297 void addMenuItem(
const std::string &
label,
const std::string &shortcut =
"",
298 const std::string &
id =
"");
300 void addSpacer(
const std::string &
id =
"",
float grow = 1.f);
305 void setItemFlexGrow(
float grow);
307 void setItemFlexShrink(
float shrink);
309 void setItemFlexBasis(
float basis);
311 void setItemAlignSelf(
const std::string &align);
313 void setItemAspectRatio(
float ratio);
315 void setItemGridColumnSpan(
int span);
320 void setItemMargin(
float l,
float t,
float r,
float b);
322 void setItemPadding(
float l,
float t,
float r,
float b);
324 void setItemMinSize(
float w,
float h);
326 void setItemMaxSize(
float w,
float h);
328 void setItemPercent(
float w,
float h);
331 void setItemAbsolute(
float anchorX,
float anchorY,
float x = 0.f,
float y = 0.f);
333 void setItemTooltip(
const std::string &
text);
344 void setItemDropTarget(
const std::string &acceptedType);
346 void setItemEnabled(
bool enabled);
351 void setItemSelected(
bool selected);
353 void setItemFocusMode(
const std::string &mode);
355 void setItemMouseFilter(
const std::string &
filter);
357 void setItemTheme(
const std::string &
theme);
359 void setThemeScope(
const std::string &
theme);
361 void setItemStyleClass(
const std::string &
name);
363 void setStyleScope(
const std::string &
name);
365 void setItemTabIndex(
int index);
367 void setItemFocusOrder(
const std::string &
previous,
const std::string &next);
369 void setItemFocusNeighbors(
const std::string &
left,
const std::string &
right,
370 const std::string &
up,
const std::string &down);
372 void setItemAccessibility(
const std::string &role,
const std::string &
name,
376 void setFlexAlign(
const std::string &align);
378 void setFlexJustify(
const std::string &justify);
380 void setLayoutGaps(
float columnGap,
float rowGap);
382 void setFlexWrap(
bool wrap);
384 void setLayoutOverflow(
const std::string &overflow);
386 void addListItem(
const std::string &
label,
const std::string &
id =
"");
391 bool mountBuildAs(
const std::string &
name);
393 bool remountBuildAs(
const std::string &
name);
399 bool setListItems(
const std::string &listId,
const std::vector<std::string> &items);
402 void setText(
const std::string &
id,
const std::string &
text);
404 void setTextWrap(
const std::string &
id,
float width);
406 void setVisible(
const std::string &
id,
bool visible);
408 void setEnabled(
const std::string &
id,
bool enabled);
410 void setChecked(
const std::string &
id,
bool checked);
412 void setValue(
const std::string &
id,
float value);
414 void setValueText(
const std::string &
id,
const std::string &
value);
416 void setColor(
const std::string &
id,
float r,
float g,
float b,
float a = 1.f);
418 void setImageTint(
const std::string &
id,
float r,
float g,
float b,
float a = 1.f);
420 void setImageUv(
const std::string &
id,
float u0,
float v0,
float u1,
float v1);
422 void setImageNinePatch(
const std::string &
id,
float l,
float t,
float r,
float b);
424 bool setImageNinePatchFile(
const std::string &
id,
const std::string &
path);
426 void setImageCornerRadius(
const std::string &
id,
float radius);
429 void setImageTextureId(
const std::string &
id, uint64_t textureId);
435 [[nodiscard(
"retain the UI texture registration id or explicitly handle failure")]]
441 void unregisterTexture(uint64_t textureId);
443 float getValue(
const std::string &
id)
const;
445 std::string getValueText(
const std::string &
id)
const;
447 float getColorR(
const std::string &
id)
const;
449 float getColorG(
const std::string &
id)
const;
451 float getColorB(
const std::string &
id)
const;
453 float getColorA(
const std::string &
id)
const;
455 bool getChecked(
const std::string &
id)
const;
457 bool requestFocus(
const std::string &
id);
459 bool moveFocus(
const std::string &
direction);
461 std::string getFocusedId()
const;
463 void setHostVisible(
bool visible);
465 void setHostLayer(
int layer);
467 void setHostModal(
bool modal);
469 void setHostOverlay(
bool overlay);
471 void setHostInputTransparent(
bool transparent);
474 void setHostHudCanvas(
float referenceWidth,
float referenceHeight,
float userScale);
476 void clearHostHudCanvas();
480 void setHostOverlayAlpha(
float alpha);
482 void setHostMovable(
bool movable);
486 void setHostPos(
float x,
float y,
float pivotX = 0.f,
float pivotY = 0.f);
493 void setHostWorldAnchor(
float x,
float y,
float z);
495 void clearHostWorldAnchor();
501 void setHostWorldEdgePolicy(
const std::string &policy,
float safeMargin = 8.f);
509 void setHostWorldDistanceScale(
bool enabled,
float referenceDistance = 10.f,
510 float minScale = 0.65f,
float maxScale = 1.25f);
518 void setHostWorldOverlap(
bool enabled,
int priority = 0,
float padding = 4.f,
519 float maxDisplacement = 96.f);
521 std::string getHostWorldState()
const;
523 float getHostWorldScreenX()
const;
525 float getHostWorldScreenY()
const;
528 void setHostAnchor(
float x,
float y);
531 void setHostSize(
float w,
float h);
534 void setHostPercent(
float w,
float h);
545 void animateHostPos(
float x,
float y,
float durationMs,
const std::string &ease =
"smoothstep",
546 float delayMs = 0.f);
555 void animateHostSize(
float w,
float h,
float durationMs,
const std::string &ease =
"smoothstep",
556 float delayMs = 0.f);
564 void animateHostOverlayAlpha(
float alpha,
float durationMs,
const std::string &ease =
"smoothstep",
565 float delayMs = 0.f);
574 void animateItemOpacity(
const std::string &
id,
float opacity,
float durationMs,
575 const std::string &ease =
"smoothstep",
float delayMs = 0.f);
585 void animateItemPos(
const std::string &
id,
float x,
float y,
float durationMs,
586 const std::string &ease =
"smoothstep",
float delayMs = 0.f);
593 void animateItemValue(
const std::string &
id,
float value,
float durationMs,
const std::string &ease =
"smoothstep",
594 float delayMs = 0.f);
596 void cancelHostTweens();
601 void cancelItemTweens(
const std::string &
id =
"");
603 void cancelAllTweens();
609 void tickTweens(
double nowMs);
611 std::size_t getHostTweenCount()
const;
613 std::size_t getItemTweenCount()
const;
615 std::string consumeClick();
617 std::string consumeChange();
619 std::string dragDropSupport()
const;
621 std::string consumeDrop();
623 std::string getDropType()
const;
625 std::string getDropText()
const;
627 std::string getDropSource()
const;
629 std::string getDropOrigin()
const;
638 void onClick(
const std::string &
id, ssq::Function
fn);
640 void onChange(
const std::string &
id, ssq::Function
fn);
642 void componentOnClick(uint64_t
owner,
const std::string &
id, ssq::Function
fn);
644 void componentOnChange(uint64_t
owner,
const std::string &
id, ssq::Function
fn);
646 void componentClearHandlers(uint64_t
owner);
651 void setThemeLight();
653 bool setTheme(
const std::string &
name);
655 std::string getTheme()
const;
660 float g,
float b,
float a = 1.f);
667 void setNavKeyboard(
bool enabled);
669 void setNavGamepad(
bool enabled);
671 void setScale(
float scale);
673 float getScale()
const;
676 std::string getStats()
const;
678 std::string getLayoutDiagnostics()
const;
680 std::string getAccessibilitySnapshot()
const;
683 std::string saveTreeJson()
const;
686 bool loadTreeJson(
const std::string &json);
698 bool viewportHovered(
const std::string &
id);
700 bool viewportActive(
const std::string &
id);
702 float viewportMouseX(
const std::string &
id);
704 float viewportMouseY(
const std::string &
id);
706 float viewportDragDX(
const std::string &
id);
708 float viewportDragDY(
const std::string &
id);
710 float viewportWheel(
const std::string &
id);
713 void mountSimple(
const std::string &
title,
const std::string &labelText,
714 const std::string &buttonText);
722 bool inspectRefresh();
724 bool inspectSelectClass(
const std::string &
name);
726 bool inspectObject(ssq::Object
object);
732 bool inspectSetPickHandler(ssq::Function
fn);
734 bool inspectPickScene();
736 bool inspectAddInstance();
746 ssq::Object propertySchema(ssq::Object instance);
756 bool dbSelectClass(
const std::string &
name);
766 [[nodiscard(
"retain the packed UI object handle or explicitly handle failure")]]
767 uint64_t dbRegister(ssq::Object
object,
const std::string &
label);
772 [[nodiscard(
"retain the packed UI object handle or explicitly handle failure")]]
773 uint64_t dbCreateInstance();
782 [[nodiscard(
"inspect the database removal result or explicitly ignore it")]]
791 bool editorSelectPanel(
const std::string &
name);
799 bool sceneSelectNode(
const std::string &
id);
805 bool sceneSetPickHandler(ssq::Function
fn);
808 struct NinePatchResource {
810 uint64_t textureId = 0;
821 NinePatchResource *loadNinePatch(
const std::string &
path);
822 void releaseNinePatches();
824 WidgetDesc ¤tParent();
825 void pushOpen(WidgetDesc
d);
826 bool buildComplete()
const;
835 UIHostHandle ensureSelected(
const std::string &preferredName =
"");
843 std::unique_ptr<UIBackend> backend_;
844 std::unordered_map<
std::
string, NinePatchResource> ninePatches_;
845 UIHostHandle selected_{};
847 std::vector<WidgetDesc> openStack_;
848 WidgetDesc builtRoot_;
849 bool hasBuiltRoot_ =
false;
850 std::string lastDropType_;
851 std::string lastDropText_;
852 std::string lastDropSource_;
853 std::string lastDropOrigin_;
855 struct ScriptHandler {
857 ScriptHandler(std::string
host, std::string
node, std::string k, ssq::Function
f,
858 uint64_t componentOwner = 0)
863 std::string hostName;
869 std::vector<ScriptHandler> scriptHandlers_;
870 void fireScriptHandlers(
const UIEvent &ev);
872 UiTweenDriver tweens_;
873 ssq::Object callPickHandler();
874 void callScenePickHandler(
const std::string &
nodeId);
875 std::unique_ptr<Inspector> inspector_;
876 std::unique_ptr<DatabasePanel> databasePanel_;
877 std::unique_ptr<EditorShell> editorShell_;
878 std::unique_ptr<ScenePanel> scenePanel_;
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.