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
fix(editor): keep a Dimension's value input visible; redesign anchor icons
esengine8a19d1bca4df
diff --git a/desktop/src/components/NumField.tsx b/desktop/src/components/NumField.tsxindex 73eec9040..5b0d3aeb5 100644--- a/desktop/src/components/NumField.tsx+++ b/desktop/src/components/NumField.tsx@@ -68,24 +68,28 @@ export function useScrub(value: number, onCommit: (n: number) => void, opts: Scr// Plain click-to-type numeric input. `suffix` (e.g. °) shows in the resting value;// `mixed` (multi-select disagreement) shows a "—" placeholder until typed over.+// `empty` shows a blank field with `placeholder` ghost text (e.g. an `auto`+// dimension) but stays editable — typing commits a value.export function NumField({value,suffix,mixed,+ empty,+ placeholder,onBegin,onEnd,onCommit,-}: ControlGesture & { value: number; suffix?: string; mixed?: boolean; onCommit: (n: number) => void }) {+}: ControlGesture & { value: number; suffix?: string; mixed?: boolean; empty?: boolean; placeholder?: string; onCommit: (n: number) => void }) {const [editing, setEditing] = useState(false);const [text, setText] = useState('');return (<span className="field"><input- value={editing ? text : mixed ? '' : fmt(value) + (suffix ?? '')}- placeholder={mixed ? '—' : undefined}+ value={editing ? text : mixed || empty ? '' : fmt(value) + (suffix ?? '')}+ placeholder={mixed ? '—' : empty ? placeholder : undefined}spellCheck={false}onFocus={() => {- setText(fmt(value));+ setText(empty ? '' : fmt(value));setEditing(true);onBegin?.();}}diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex 4045f90a0..afa3711a3 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -410,8 +410,10 @@ export function BoolControl({);}-// A CSS-length: a number well + a px/%/auto unit picker. `auto` drops the number-// (Yoga ignores its value), so the well collapses to a static "auto" label.+// A CSS-length: a number well + a px/%/auto unit picker. The well is ALWAYS shown+// and editable — for `auto` it's blank with a ghost "auto" placeholder, and typing+// a value flips the unit to px (Yoga ignores an `auto` unit's number, so there's no+// value to type against otherwise).export function DimControl({value,mixed,@@ -419,6 +421,7 @@ export function DimControl({onEnd,onChange,}: ControlGesture & { value: DimensionValue; mixed?: boolean; onChange: (v: DimensionValue) => void }) {+ const isAuto = value.unit === DimensionUnit.Auto;const setUnit = (unit: number) => {onBegin?.();onChange({ value: value.value, unit });@@ -426,19 +429,14 @@ export function DimControl({};return (<div className="dim">- {value.unit === DimensionUnit.Auto ? (- // 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>- ) : (- <NumField- value={value.value}- mixed={mixed}- onBegin={onBegin}- onEnd={onEnd}- onCommit={(n) => onChange({ value: n, unit: value.unit })}- />- )}+ <NumField+ value={value.value}+ mixed={mixed}+ empty={isAuto}+ onBegin={onBegin}+ onEnd={onEnd}+ onCommit={(n) => onChange({ value: n, unit: isAuto ? DimensionUnit.Px : value.unit })}+ /><Selectvariant="field"value={String(value.unit)}@@ -1108,20 +1106,19 @@ const ANCHOR_V = { [AnchorAxis.Start]: 'Top', [AnchorAxis.Center]: 'Middle', [Anconst 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;+// The widget rect (in a 24×24 cell viewBox) a preset draws: a small rounded box for+// a pinned corner/edge/centre, stretched along a Stretch axis, filling the frame+// when both axes stretch — the element shown inside its parent (the cell).+function anchorWidgetRect(h: AnchorAxis, v: AnchorAxis) {+ const axis = (mode: AnchorAxis, crossStretch: boolean) => {+ if (mode === AnchorAxis.Stretch) return { p: 4, s: 16 };+ const s = crossStretch ? 5 : 8; // a thin bar's cross-section vs a box's side+ const c = mode === AnchorAxis.Start ? 7 : mode === AnchorAxis.End ? 17 : 12;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' };+ const hx = axis(h, v === AnchorAxis.Stretch);+ const vy = axis(v, h === AnchorAxis.Stretch);+ return { x: hx.p, y: vy.p, w: hx.s, h: vy.s };}/** UMG/Unity-style anchor preset picker for a UINode: a 4×4 grid (Left/Center/@@ -1158,7 +1155,14 @@ function AnchorPresetGrid({ entities, comp }: { entities: EntityId[]; comp: Insparia-pressed={on}onClick={() => SceneCommands.setUINodeAnchor(entities, { h, v })}>- <span className="anchor-mark" style={anchorMarkStyle(h, v)} />+ {(() => {+ const r = anchorWidgetRect(h, v);+ return (+ <svg className="anchor-svg" viewBox="0 0 24 24" aria-hidden="true">+ <rect className="anchor-widget" x={r.x} y={r.y} width={r.w} height={r.h} rx="1.6" ry="1.6" />+ </svg>+ );+ })()}</button>);}),diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.cssindex 291f264e8..9f801fa73 100644--- a/desktop/src/theme/inspector.css+++ b/desktop/src/theme/inspector.css@@ -86,9 +86,10 @@.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); 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); }+.anchor-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }+.anchor-widget { fill: var(--text-mute); transition: fill var(--t-fast); }+.anchor-cell:hover .anchor-widget { fill: var(--text); }+.anchor-cell.active .anchor-widget { fill: var(--acc-hi); }/* property rows (label col + value col, reset on right) */.prop { display: grid; grid-template-columns: 38% 1fr 18px; align-items: center; gap: 4px; min-height: var(--h-prop); padding: 1px 0; position: relative; }