A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): polish the UINode inspector section
esengine058d17aaf51b
diff --git a/desktop/src/engine/schema.ts b/desktop/src/engine/schema.tsindex 57c0e110f..691be2f0b 100644--- a/desktop/src/engine/schema.ts+++ b/desktop/src/engine/schema.ts@@ -381,6 +381,18 @@ export function isRequiredField(compType: string, key: string): boolean {return userSchema(compType)?.fields?.[key]?.required === true;}+// Editor-side "Advanced" fold policy — rarely-tuned fields moved below the fold so a+// component's common controls stay uncluttered. UINode's flex-item knobs (min/max,+// grow/shrink/basis, cross-axis alignSelf) are set far less than its size/anchor.+const ADVANCED_FIELDS: Record<string, readonly string[]> = {+ UINode: ['minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'flexGrow', 'flexShrink', 'flexBasis', 'alignSelf'],+};++/** Whether a field lives under the "Advanced" fold (builtin table OR its own metadata). */+export function isAdvancedField(compType: string, key: string): boolean {+ return ADVANCED_FIELDS[compType]?.includes(key) === true;+}+/** The dropdown options for an enum field, or null if the field isn't an enum. */export function enumFieldOptions(compType: string, key: string): EnumOption[] | null {const e = fieldMetaFor(compType, key)?.enum;@@ -458,7 +470,7 @@ function fieldFor(}// Presentation policy that applies to any field type (folds, category, help text,// and a DisplayName override of the key-derived label).- if (field && meta?.advanced) field.advanced = true;+ if (field && (meta?.advanced || isAdvancedField(compType, key))) field.advanced = true;if (field && meta?.category) field.category = meta.category;if (field && meta?.tooltip) field.tooltip = meta.tooltip;if (field && meta?.label) field.label = meta.label;diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex 94eabfd8f..4045f90a0 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -427,7 +427,9 @@ export function DimControl({return (<div className="dim">{value.unit === DimensionUnit.Auto ? (- <span className="field dim-auto">auto</span>+ // The unit dropdown already reads "auto"; a dimmed dash marks "no value"+ // instead of a redundant second "auto".+ <span className="field dim-auto" aria-hidden="true">–</span>) : (<NumFieldvalue={value.value}@@ -1101,20 +1103,27 @@ function textBoxAction(comp: InspectorComponent, sourceId: EntityId): { label: s};}-// Where a preset's mark sits inside its cell (percent of the cell box), per axis-// mode. Start/Center/End are a 30%-wide dot at the near/mid/far third; Stretch is-// a bar filling the axis — a glanceable picture of the anchor.-const ANCHOR_MARK: Record<number, { start: number; size: number }> = {- [AnchorAxis.Start]: { start: 14, size: 30 },- [AnchorAxis.Center]: { start: 35, size: 30 },- [AnchorAxis.End]: { start: 56, size: 30 },- [AnchorAxis.Stretch]: { start: 12, size: 76 },-};const ANCHOR_H = { [AnchorAxis.Start]: 'Left', [AnchorAxis.Center]: 'Center', [AnchorAxis.End]: 'Right', [AnchorAxis.Stretch]: 'Stretch H' };const ANCHOR_V = { [AnchorAxis.Start]: 'Top', [AnchorAxis.Center]: 'Middle', [AnchorAxis.End]: 'Bottom', [AnchorAxis.Stretch]: 'Stretch V' };const anchorTitle = (h: AnchorAxis, v: AnchorAxis) =>h === AnchorAxis.Stretch && v === AnchorAxis.Stretch ? 'Stretch' : `${ANCHOR_V[v]} · ${ANCHOR_H[h]}`;+// The mark inside a preset cell: a dot for a pinned corner/edge/centre, a thin bar+// along a stretched axis, a rounded square when both axes stretch — a glanceable+// picture of where the element sits in its parent box.+function anchorMarkStyle(h: AnchorAxis, v: AnchorAxis) {+ const ext = (mode: AnchorAxis, crossStretch: boolean) => {+ if (mode === AnchorAxis.Stretch) return { p: 16, s: 68 };+ const s = crossStretch ? 12 : 30; // a thin bar's cross-section vs a dot's diameter+ const c = mode === AnchorAxis.Start ? 27 : mode === AnchorAxis.End ? 73 : 50;+ return { p: c - s / 2, s };+ };+ const hx = ext(h, v === AnchorAxis.Stretch);+ const vy = ext(v, h === AnchorAxis.Stretch);+ const isDot = h !== AnchorAxis.Stretch && v !== AnchorAxis.Stretch;+ return { left: `${hx.p}%`, top: `${vy.p}%`, width: `${hx.s}%`, height: `${vy.s}%`, borderRadius: isDot ? '50%' : '2px' };+}+/** UMG/Unity-style anchor preset picker for a UINode: a 4×4 grid (Left/Center/* Right/Stretch × Top/Middle/Bottom/Stretch) that writes position + inset/margin* box fields, and highlights the cell the current box already matches. Making the@@ -1134,29 +1143,27 @@ function AnchorPresetGrid({ entities, comp }: { entities: EntityId[]; comp: Insp} as Parameters<typeof detectAnchor>[0];const active = detectAnchor(node);return (- <div className="anchor-grid" role="group" aria-label="Anchor preset">- {ANCHOR_AXES.map((v) =>- ANCHOR_AXES.map((h) => {- const on = active != null && active.h === h && active.v === v;- const hm = ANCHOR_MARK[h];- const vm = ANCHOR_MARK[v];- return (- <button- key={`${v}-${h}`}- type="button"- className={`anchor-cell${on ? ' active' : ''}`}- title={anchorTitle(h, v)}- aria-pressed={on}- onClick={() => SceneCommands.setUINodeAnchor(entities, { h, v })}- >- <span- className="anchor-mark"- style={{ left: `${hm.start}%`, width: `${hm.size}%`, top: `${vm.start}%`, height: `${vm.size}%` }}- />- </button>- );- }),- )}+ <div className="anchor-block">+ <span className="anchor-caption">Anchor{active && <em>{anchorTitle(active.h, active.v)}</em>}</span>+ <div className="anchor-grid" role="group" aria-label="Anchor preset">+ {ANCHOR_AXES.map((v) =>+ ANCHOR_AXES.map((h) => {+ const on = active != null && active.h === h && active.v === v;+ return (+ <button+ key={`${v}-${h}`}+ type="button"+ className={`anchor-cell${on ? ' active' : ''}`}+ title={anchorTitle(h, v)}+ aria-pressed={on}+ onClick={() => SceneCommands.setUINodeAnchor(entities, { h, v })}+ >+ <span className="anchor-mark" style={anchorMarkStyle(h, v)} />+ </button>+ );+ }),+ )}+ </div></div>);}diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.cssindex d4acdcde6..291f264e8 100644--- a/desktop/src/theme/inspector.css+++ b/desktop/src/theme/inspector.css@@ -76,13 +76,17 @@.comp-action { margin: 6px 8px 0; padding: 4px 8px; width: calc(100% - 16px); font-size: var(--fs-2xs); color: var(--text); background: var(--srf-3); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }.comp-action:hover { background: var(--srf-4); border-color: var(--acc); }-/* Anchor preset picker (UINode): a 4×4 grid of parent boxes, each showing where- the anchored element would sit; the cell matching the live box is highlighted. */-.anchor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin: 6px 8px 2px; width: max-content; }+/* Anchor preset picker (UINode): a 4×4 grid of parent boxes; each cell's mark shows+ where the element sits (dot = pinned corner/edge/centre, bar = stretch). The cell+ matching the live box is lit, and the caption names the active preset. */+.anchor-block { padding: 5px 8px 7px; }+.anchor-caption { display: flex; align-items: baseline; gap: 7px; font-size: var(--fs-2xs); color: var(--text-dim); margin-bottom: 6px; }+.anchor-caption em { font-style: normal; color: var(--acc-hi); }+.anchor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: max-content; padding: 5px; background: var(--srf-2); border: 1px solid var(--border-soft); border-radius: var(--r-sm); }.anchor-cell { position: relative; width: 26px; height: 26px; padding: 0; background: var(--srf-3); border: 1px solid var(--border); border-radius: var(--r-xs); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }.anchor-cell:hover { border-color: var(--acc); background: var(--srf-4); }-.anchor-cell.active { border-color: var(--acc); background: var(--acc-soft); }-.anchor-mark { position: absolute; background: var(--text-dim); border-radius: 1px; pointer-events: none; }+.anchor-cell.active { border-color: var(--acc); background: var(--acc-soft); box-shadow: inset 0 0 0 1px var(--acc); }+.anchor-mark { position: absolute; background: var(--text-mute); pointer-events: none; transition: background var(--t-fast); }.anchor-cell:hover .anchor-mark { background: var(--text); }.anchor-cell.active .anchor-mark { background: var(--acc-hi); }