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
@@ -1,5 +1,5 @@
|
||||
import type { AssetType } from '../../core/model/AssetTypes';
|
||||
import { Button, Label, Panel, Widget, activeDrag, currentMenu, ui } from '../../ui';
|
||||
import { Button, Label, Panel, TextField, Widget, activeDrag, currentMenu, ui } from '../../ui';
|
||||
import { Theme } from '../../ui/Theme';
|
||||
import { currentFontPicker } from '../font/FontPicker';
|
||||
import { currentSoundPicker } from '../sound/SoundPicker';
|
||||
@@ -142,7 +142,8 @@ export function uiHooks({ app, state, editor }: HookContext) {
|
||||
inspectorField: fieldOf,
|
||||
/**
|
||||
* The label of an inspector row as a link (#221): its centre, colour and whether it is underlined
|
||||
* and takes presses. Searched in the inspector only – the tab row says "Shader" too.
|
||||
* and takes presses, and a text field right of it (value, read-only). Searched in the inspector
|
||||
* only – the tab row says "Shader" too.
|
||||
*/
|
||||
inspectorLink: (text: string) => {
|
||||
let found: Label | null = null;
|
||||
@@ -155,7 +156,10 @@ export function uiHooks({ app, state, editor }: HookContext) {
|
||||
const label = found as Label | null;
|
||||
if (!label) return null;
|
||||
const shown = label.children.find((child): child is Text => child instanceof Text);
|
||||
const row = label.parent;
|
||||
const next = row?.children[row.children.indexOf(label) + 1];
|
||||
return {
|
||||
field: next instanceof TextField ? { value: next.value, readOnly: next.readOnly } : null,
|
||||
...centreOf(label),
|
||||
color: shown ? new Color(shown.style.fill as ColorSource).toHex() : null,
|
||||
underlined: label.underlined,
|
||||
@@ -238,6 +242,8 @@ export function uiHooks({ app, state, editor }: HookContext) {
|
||||
/** An asset's row, its group unfolded first as a user would; `assetRowShown` leaves it folded. */
|
||||
assetRow: (id: string) => assets.rowGlobal(id, true),
|
||||
assetRowShown: (id: string) => assets.rowGlobal(id),
|
||||
/** The asset row lighting up after a ping (#221) and how brightly, or null once it has faded. */
|
||||
assetPing: () => assets.pingState(),
|
||||
assetRowColor: (id: string) => assets.rowColor(id),
|
||||
/** The asset panel's groups in order; a heading's row is `assetRow('group:<type>')`. */
|
||||
assetGroups: () => assets.groups(),
|
||||
|
||||
Reference in new issue
Block a user