Ping an asset from its inspector link instead of selecting it (#221)
A single click on an asset link used to select the asset. That swapped
the inspector over to the asset, so the object being edited was gone
and the second click of a double-click landed on a different row. A
click now pings the asset in the asset panel, like Unity does in its
Project window, and a double-click opens it.
- state.pingAsset(id) emits a new `ping` event. It runs no command and
leaves the selection alone, like openAsset.
- ListView.ping(id) draws an accent overlay on the row. It stays full
for 200 ms and is gone after 1 s, driven by onFrame. destroy cancels
the animation.
- The asset panel expands the group, scrolls to the row and pings it.
- The capture listener and followedLink in the inspector are gone.
The inspector is no longer rebuilt, so pressCount on the label is
enough. followsPress and pressOf are no longer exported from ui/.
- The "Asset" and "Part of" rows of a scene object were a ghost button
that selected the asset. They are now a link label with the same
ping and open behaviour, next to a read-only field with the name.
- The link logic lives in linkLabel() in fieldFactory.ts. createFieldRow
and the asset row share it.
- TextField gets a readOnly option: no focus, no caret, no hover.
- New hook __gm.assetPing(). inspectorLink also reports the field
next to the label (value, readOnly).
Findings:
- Renaming an asset while its object was selected left the old name
in the inspector. This was already the case with the old button.
The refresh now updates the name.
Tests:
- ./check.sh: 151 files, 2228 tests, CHECK EXIT 0 (before 150 / 2226).
New: tests/ui/list-ping.test.ts for pingAlpha and pingAsset.
- e2e 1-16,28 on the final build: ALL PASSED, 575 checks.
28l-ii has 9 checks instead of 5.
- Counter-checks, each failing exactly at its check: ping also selects,
no follow-up frame (alpha stays 0.55), inspector never opens, field
takes focus, name not refreshed, label not a link.
- Check total 1345, calculated. CI last counted 1336 at fd6af84.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1aae97b335
commit
2cf72022eb
12 files changed
+282
-79
No files matched your search
@@ -25,7 +25,7 @@ import {
|
||||
type ObjectRef,
|
||||
resolvedHolder,
|
||||
} from '../../core/model/instance';
|
||||
import type { PropertyValue } from '../../core/model/Properties';
|
||||
import { type PropertyValue, textOf } from '../../core/model/Properties';
|
||||
import { findAsset, findObjectHolder, type Project } from '../../core/model/Project';
|
||||
import type { SceneObject } from '../../core/model/SceneObject';
|
||||
import {
|
||||
@@ -42,11 +42,18 @@ import {
|
||||
deviatesFromTemplate,
|
||||
resolveSceneObjectProps,
|
||||
} from '../../core/properties/resolve';
|
||||
import { Button, Theme } from '../../ui';
|
||||
import { Button, TextField, Theme } from '../../ui';
|
||||
import { createContainer, removeObjects } from '../actions';
|
||||
import { aspectActions, sizeCommand } from './aspectAction';
|
||||
import { defSignature } from './assetSection';
|
||||
import { actionIf, createFieldRow, type FieldRow, labelledRow, type RowActions } from './fieldFactory';
|
||||
import {
|
||||
actionIf,
|
||||
createFieldRow,
|
||||
type FieldRow,
|
||||
labelledRow,
|
||||
linkLabel,
|
||||
type RowActions,
|
||||
} from './fieldFactory';
|
||||
import { addGap, addNameField, addNote, addTitle, type InspectorHost } from './host';
|
||||
import type { EditorState, ListSlot } from '../state';
|
||||
import { parentRow } from './parentRow';
|
||||
@@ -139,10 +146,10 @@ export function buildObjectSection(host: InspectorHost, holderId: string, object
|
||||
placeholder: asset.name,
|
||||
onChange: (name) => host.state.execute(new RenameSceneObjectCommand(holderId, objectId, name.trim())),
|
||||
});
|
||||
assetLink(host, 'Asset', asset);
|
||||
assetLink(host, ASSET_ROW, 'Asset', asset);
|
||||
host.body.add(parentRow(host, view, object, target !== undefined));
|
||||
// Content of a placed container: values compare against the template, not just the asset.
|
||||
if (target) assetLink(host, 'Part of', target.asset);
|
||||
if (target) assetLink(host, PART_OF_ROW, 'Part of', target.asset);
|
||||
|
||||
// The master switch, right where it is looked for: above everything type-specific.
|
||||
const resolved = resolveSceneObjectProps(host.state.project, asset, object);
|
||||
@@ -241,16 +248,21 @@ function gridEdgesSection(host: InspectorHost, holderId: string, object: SceneOb
|
||||
} else addNote(host, 'The painted cells stay where they are in the scene.', 'small');
|
||||
}
|
||||
|
||||
function assetLink(host: InspectorHost, label: string, asset: Asset): void {
|
||||
const { row } = labelledRow(label);
|
||||
row.add(
|
||||
new Button(asset.name, {
|
||||
variant: 'ghost',
|
||||
onClick: () => host.state.select({ kind: 'asset', assetId: asset.id }),
|
||||
}),
|
||||
1,
|
||||
);
|
||||
/** Registry keys of the two asset rows; `#` keeps them clear of property keys. */
|
||||
const ASSET_ROW = '#asset';
|
||||
const PART_OF_ROW = '#part-of';
|
||||
|
||||
/**
|
||||
* What the object was placed from: the label is a link like on any reference row (click pings,
|
||||
* double-click opens), the name next to it only reads – changing it would mean another object.
|
||||
*/
|
||||
function assetLink(host: InspectorHost, key: string, text: string, asset: Asset): void {
|
||||
const { row, label } = labelledRow(text);
|
||||
linkLabel(host, label)(asset.id);
|
||||
const name = new TextField(asset.name, { readOnly: true });
|
||||
row.add(name, 1);
|
||||
host.body.add(row);
|
||||
host.fields.set(key, { row, setValue: (v) => name.setValue(textOf(v)), setModified: () => {} });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,12 +307,16 @@ export function refreshObjectSection(host: InspectorHost, holderId: string, obje
|
||||
const asset = object && findAsset(project, object.assetId);
|
||||
if (!view || !object || !asset) return false;
|
||||
host.nameField?.setValue(object.name);
|
||||
// A rename of the asset changes no structure, so it arrives here rather than as a rebuild.
|
||||
host.fields.get(ASSET_ROW)?.setValue(asset.name);
|
||||
const target = targetOf(project, holderId, objectId);
|
||||
if (target) host.fields.get(PART_OF_ROW)?.setValue(target.asset.name);
|
||||
for (const axis of POSITION_AXES) host.fields.get(axis)?.setValue(object.position[axis]);
|
||||
for (const axis of OFFSET_AXES) host.fields.get(offsetKey(axis))?.setValue(object.editorOffset[axis]);
|
||||
const values = resolveSceneObjectProps(project, asset, object);
|
||||
for (const def of schemaForObject(project, asset, object))
|
||||
host.fields.get(def.key)?.setValue(values[def.key] ?? def.default);
|
||||
markObjectRows(host, object, asset, targetOf(project, holderId, objectId));
|
||||
markObjectRows(host, object, asset, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user