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 =
"");
187 void beginScrollList(
const std::string &
id =
"",
float height = 0.f,
float itemHeight = 0.f);
194 void beginFlex(
const std::string &
direction =
"row",
const std::string &
id =
"",
197 void beginRow(
const std::string &
id =
"",
float gap = -1.f);
199 void beginColumn(
const std::string &
id =
"",
float gap = -1.f);
201 void beginGrid(
int columns,
const std::string &
id =
"",
float columnGap = -1.f,
202 float rowGap = -1.f);
206 void addText(
const std::string &content,
const std::string &
id =
"");
209 void addTextWrapped(
const std::string &content,
float width,
const std::string &
id =
"");
211 void addButton(
const std::string &
label,
const std::string &
id =
"");
213 void addIcon(
const std::string &
name,
const std::string &
id =
"");
215 void addIconButton(
const std::string &
name,
const std::string &
label =
"",
216 const std::string &
id =
"");
218 void addSameLine(
const std::string &
id =
"");
220 void addSeparator(
const std::string &
id =
"");
222 void addCheckbox(
const std::string &
label,
bool checked,
const std::string &
id =
"");
224 void addSlider(
const std::string &
label,
float value,
float minV,
float maxV,
225 const std::string &
id =
"");
230 void addColorPalette(
const std::string &
label,
float r,
float g,
float b,
float a = 1.f,
231 const std::string &
id =
"");
233 void addProgress(
float fraction,
const std::string &
id =
"",
const std::string &overlay =
"");
236 void addImage(
const std::string &
id =
"",
float width = 0.f,
float height = 0.f);
238 bool addNinePatch(
const std::string &
path,
const std::string &
id =
"",
242 void addImageButton(
const std::string &
id,
float width,
float height);
245 void addViewport(
const std::string &
id,
float width = 0.f,
float height = 0.f);
248 void addCombo(
const std::string &
label,
const std::string &
options,
int selected,
249 const std::string &
id =
"");
251 void addInputText(
const std::string &
label,
const std::string &
value,
const std::string &
id =
"");
253 void addSearchField(
const std::string &hint,
const std::string &
value =
"",
254 const std::string &
id =
"");
256 void addSwitch(
const std::string &
label,
bool checked,
const std::string &
id =
"");
258 void addBadge(
const std::string &
label,
const std::string &
id =
"");
260 void addSectionHeader(
const std::string &
label,
const std::string &
id =
"");
262 void addMenuItem(
const std::string &
label,
const std::string &shortcut =
"",
263 const std::string &
id =
"");
265 void addSpacer(
const std::string &
id =
"",
float grow = 1.f);
270 void setItemFlexGrow(
float grow);
272 void setItemFlexShrink(
float shrink);
274 void setItemFlexBasis(
float basis);
276 void setItemAlignSelf(
const std::string &align);
278 void setItemAspectRatio(
float ratio);
280 void setItemGridColumnSpan(
int span);
285 void setItemMargin(
float l,
float t,
float r,
float b);
287 void setItemPadding(
float l,
float t,
float r,
float b);
289 void setItemMinSize(
float w,
float h);
291 void setItemMaxSize(
float w,
float h);
293 void setItemPercent(
float w,
float h);
296 void setItemAbsolute(
float anchorX,
float anchorY,
float x = 0.f,
float y = 0.f);
298 void setItemTooltip(
const std::string &
text);
309 void setItemDropTarget(
const std::string &acceptedType);
311 void setItemEnabled(
bool enabled);
316 void setItemSelected(
bool selected);
318 void setItemFocusMode(
const std::string &mode);
320 void setItemMouseFilter(
const std::string &
filter);
322 void setItemTheme(
const std::string &
theme);
324 void setThemeScope(
const std::string &
theme);
326 void setItemStyleClass(
const std::string &
name);
328 void setStyleScope(
const std::string &
name);
330 void setItemTabIndex(
int index);
332 void setItemFocusOrder(
const std::string &
previous,
const std::string &next);
334 void setItemFocusNeighbors(
const std::string &
left,
const std::string &
right,
335 const std::string &
up,
const std::string &down);
337 void setItemAccessibility(
const std::string &role,
const std::string &
name,
341 void setFlexAlign(
const std::string &align);
343 void setFlexJustify(
const std::string &justify);
345 void setLayoutGaps(
float columnGap,
float rowGap);
347 void setFlexWrap(
bool wrap);
349 void setLayoutOverflow(
const std::string &overflow);
351 void addListItem(
const std::string &
label,
const std::string &
id =
"");
356 bool mountBuildAs(
const std::string &
name);
358 bool remountBuildAs(
const std::string &
name);
364 bool setListItems(
const std::string &listId,
const std::vector<std::string> &items);
367 void setText(
const std::string &
id,
const std::string &
text);
369 void setTextWrap(
const std::string &
id,
float width);
371 void setVisible(
const std::string &
id,
bool visible);
373 void setEnabled(
const std::string &
id,
bool enabled);
375 void setChecked(
const std::string &
id,
bool checked);
377 void setValue(
const std::string &
id,
float value);
379 void setValueText(
const std::string &
id,
const std::string &
value);
381 void setColor(
const std::string &
id,
float r,
float g,
float b,
float a = 1.f);
383 void setImageTint(
const std::string &
id,
float r,
float g,
float b,
float a = 1.f);
385 void setImageUv(
const std::string &
id,
float u0,
float v0,
float u1,
float v1);
387 void setImageNinePatch(
const std::string &
id,
float l,
float t,
float r,
float b);
389 bool setImageNinePatchFile(
const std::string &
id,
const std::string &
path);
391 void setImageCornerRadius(
const std::string &
id,
float radius);
394 void setImageTextureId(
const std::string &
id, uint64_t textureId);
400 [[nodiscard(
"retain the UI texture registration id or explicitly handle failure")]]
406 void unregisterTexture(uint64_t textureId);
408 float getValue(
const std::string &
id)
const;
410 std::string getValueText(
const std::string &
id)
const;
412 float getColorR(
const std::string &
id)
const;
414 float getColorG(
const std::string &
id)
const;
416 float getColorB(
const std::string &
id)
const;
418 float getColorA(
const std::string &
id)
const;
420 bool getChecked(
const std::string &
id)
const;
422 bool requestFocus(
const std::string &
id);
424 bool moveFocus(
const std::string &
direction);
426 std::string getFocusedId()
const;
428 void setHostVisible(
bool visible);
430 void setHostLayer(
int layer);
432 void setHostModal(
bool modal);
434 void setHostOverlay(
bool overlay);
436 void setHostOverlayAlpha(
float alpha);
438 void setHostMovable(
bool movable);
442 void setHostPos(
float x,
float y,
float pivotX = 0.f,
float pivotY = 0.f);
449 void setHostWorldAnchor(
float x,
float y,
float z);
451 void clearHostWorldAnchor();
457 void setHostWorldEdgePolicy(
const std::string &policy,
float safeMargin = 8.f);
465 void setHostWorldDistanceScale(
bool enabled,
float referenceDistance = 10.f,
466 float minScale = 0.65f,
float maxScale = 1.25f);
474 void setHostWorldOverlap(
bool enabled,
int priority = 0,
float padding = 4.f,
475 float maxDisplacement = 96.f);
477 std::string getHostWorldState()
const;
479 float getHostWorldScreenX()
const;
481 float getHostWorldScreenY()
const;
484 void setHostAnchor(
float x,
float y);
487 void setHostSize(
float w,
float h);
490 void setHostPercent(
float w,
float h);
501 void animateHostPos(
float x,
float y,
float durationMs,
const std::string &ease =
"smoothstep",
502 float delayMs = 0.f);
511 void animateHostSize(
float w,
float h,
float durationMs,
const std::string &ease =
"smoothstep",
512 float delayMs = 0.f);
520 void animateHostOverlayAlpha(
float alpha,
float durationMs,
const std::string &ease =
"smoothstep",
521 float delayMs = 0.f);
530 void animateItemOpacity(
const std::string &
id,
float opacity,
float durationMs,
531 const std::string &ease =
"smoothstep",
float delayMs = 0.f);
541 void animateItemPos(
const std::string &
id,
float x,
float y,
float durationMs,
542 const std::string &ease =
"smoothstep",
float delayMs = 0.f);
544 void cancelHostTweens();
549 void cancelItemTweens(
const std::string &
id =
"");
551 void cancelAllTweens();
557 void tickTweens(
double nowMs);
559 std::size_t getHostTweenCount()
const;
561 std::size_t getItemTweenCount()
const;
563 std::string consumeClick();
565 std::string consumeChange();
567 std::string dragDropSupport()
const;
569 std::string consumeDrop();
571 std::string getDropType()
const;
573 std::string getDropText()
const;
575 std::string getDropSource()
const;
577 std::string getDropOrigin()
const;
586 void onClick(
const std::string &
id, ssq::Function
fn);
588 void onChange(
const std::string &
id, ssq::Function
fn);
590 void componentOnClick(uint64_t owner,
const std::string &
id, ssq::Function
fn);
592 void componentOnChange(uint64_t owner,
const std::string &
id, ssq::Function
fn);
594 void componentClearHandlers(uint64_t owner);
599 void setThemeLight();
601 bool setTheme(
const std::string &
name);
603 std::string getTheme()
const;
608 float g,
float b,
float a = 1.f);
615 void setNavKeyboard(
bool enabled);
617 void setNavGamepad(
bool enabled);
619 void setScale(
float scale);
621 float getScale()
const;
624 std::string getStats()
const;
626 std::string getLayoutDiagnostics()
const;
628 std::string getAccessibilitySnapshot()
const;
631 std::string saveTreeJson()
const;
634 bool loadTreeJson(
const std::string &json);
646 bool viewportHovered(
const std::string &
id);
648 bool viewportActive(
const std::string &
id);
650 float viewportMouseX(
const std::string &
id);
652 float viewportMouseY(
const std::string &
id);
654 float viewportDragDX(
const std::string &
id);
656 float viewportDragDY(
const std::string &
id);
658 float viewportWheel(
const std::string &
id);
661 void mountSimple(
const std::string &
title,
const std::string &labelText,
662 const std::string &buttonText);
670 bool inspectRefresh();
672 bool inspectSelectClass(
const std::string &
name);
674 bool inspectObject(ssq::Object
object);
680 bool inspectSetPickHandler(ssq::Function
fn);
682 bool inspectPickScene();
684 bool inspectAddInstance();
694 ssq::Object propertySchema(ssq::Object instance);
704 bool dbSelectClass(
const std::string &
name);
714 [[nodiscard(
"retain the packed UI object handle or explicitly handle failure")]]
715 uint64_t dbRegister(ssq::Object
object,
const std::string &
label);
720 [[nodiscard(
"retain the packed UI object handle or explicitly handle failure")]]
721 uint64_t dbCreateInstance();
730 [[nodiscard(
"inspect the database removal result or explicitly ignore it")]]
739 bool editorSelectPanel(
const std::string &
name);
747 bool sceneSelectNode(
const std::string &
id);
753 bool sceneSetPickHandler(ssq::Function
fn);
756 struct NinePatchResource {
758 uint64_t textureId = 0;
769 NinePatchResource *loadNinePatch(
const std::string &
path);
770 void releaseNinePatches();
772 WidgetDesc ¤tParent();
773 void pushOpen(WidgetDesc
d);
774 bool buildComplete()
const;
783 UIHostHandle ensureSelected(
const std::string &preferredName =
"");
791 std::unique_ptr<UIBackend> backend_;
792 std::unordered_map<
std::
string, NinePatchResource> ninePatches_;
793 UIHostHandle selected_{};
795 std::vector<WidgetDesc> openStack_;
796 WidgetDesc builtRoot_;
797 bool hasBuiltRoot_ =
false;
798 std::string lastDropType_;
799 std::string lastDropText_;
800 std::string lastDropSource_;
801 std::string lastDropOrigin_;
803 struct ScriptHandler {
805 ScriptHandler(std::string
host, std::string
node, std::string k, ssq::Function
f,
806 uint64_t componentOwner = 0)
810 fn(
std::move(
f)), owner(componentOwner) {}
811 std::string hostName;
817 std::vector<ScriptHandler> scriptHandlers_;
818 void fireScriptHandlers(
const UIEvent &ev);
820 UiTweenDriver tweens_;
821 ssq::Object callPickHandler();
822 void callScenePickHandler(
const std::string &
nodeId);
823 std::unique_ptr<Inspector> inspector_;
824 std::unique_ptr<DatabasePanel> databasePanel_;
825 std::unique_ptr<EditorShell> editorShell_;
826 std::unique_ptr<ScenePanel> scenePanel_;
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.