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
@@ -55,7 +55,7 @@ export interface FieldContext {
|
||||
project(): Project;
|
||||
/**
|
||||
* A press on the label of a reference row that names an asset (#221). Without it the label stays
|
||||
* plain text – only the inspector knows how a second press on a rebuilt panel opens the asset.
|
||||
* plain text – only the inspector knows what a click (ping) and a double-click (open) do.
|
||||
*/
|
||||
followReference?(assetId: string, e: FederatedPointerEvent): void;
|
||||
}
|
||||
@@ -226,24 +226,13 @@ export function createFieldRow(
|
||||
|
||||
const refreshActions = attachRowActions(row, rowActions);
|
||||
|
||||
const follow = ctx.followReference?.bind(ctx);
|
||||
const paintLabel = linkLabel(ctx, label);
|
||||
let modified = false;
|
||||
let target: string | null = null;
|
||||
const paintLabel = (): void => {
|
||||
// An override keeps its colour: that it deviates says more than that it can be followed.
|
||||
label.setStyle(modified ? 'override' : target ? 'link' : 'muted');
|
||||
label.setUnderline(target !== null);
|
||||
label.eventMode = target ? 'static' : 'none';
|
||||
};
|
||||
const retarget = (v: PropertyValue): void => {
|
||||
if (!follow) return;
|
||||
target = referencedAssetId(ctx.project(), def, v);
|
||||
paintLabel();
|
||||
paintLabel(target, modified);
|
||||
};
|
||||
if (follow)
|
||||
label.on('pointerdown', (e: FederatedPointerEvent) => {
|
||||
if (e.button === 0 && target) follow(target, e);
|
||||
});
|
||||
retarget(value);
|
||||
|
||||
return {
|
||||
@@ -254,12 +243,36 @@ export function createFieldRow(
|
||||
},
|
||||
setModified(isModified) {
|
||||
modified = isModified;
|
||||
paintLabel();
|
||||
paintLabel(target, modified);
|
||||
refreshActions();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a row label into a link to an asset (#221): blue and underlined while it names one, a
|
||||
* click pings it, a double-click opens it. Returns the repaint, to be called whenever the target
|
||||
* or the modified state changes. Without `followReference` the label stays plain text.
|
||||
*/
|
||||
export function linkLabel(
|
||||
ctx: FieldContext,
|
||||
label: Label,
|
||||
): (target: string | null, modified?: boolean) => void {
|
||||
const follow = ctx.followReference?.bind(ctx);
|
||||
let target: string | null = null;
|
||||
if (follow)
|
||||
label.on('pointerdown', (e: FederatedPointerEvent) => {
|
||||
if (e.button === 0 && target) follow(target, e);
|
||||
});
|
||||
return (next, modified = false) => {
|
||||
target = follow ? next : null;
|
||||
// An override keeps its colour: that it deviates says more than that it can be followed.
|
||||
label.setStyle(modified ? 'override' : target ? 'link' : 'muted');
|
||||
label.setUnderline(target !== null);
|
||||
label.eventMode = target ? 'static' : 'none';
|
||||
};
|
||||
}
|
||||
|
||||
interface Field {
|
||||
widget: Widget;
|
||||
/** Whether the widget should take the remaining row width. */
|
||||
|
||||
Reference in new issue
Block a user