Pick the target of an object variable in the Scene View (#276)
Choosing the target of an object variable meant finding its name in a dropdown. With many objects, or several with the same sprite, the name alone does not say which one it is. The eyedropper lets you click the object where you see it instead. - Every object dropdown gets an eyedropper button next to it. This covers variables, struct fields and list entries, in the Inspector and in the Variables tab. - The button opens the Scene View or the container tab the object lives in. A strip above the view names the field and the current candidate and offers Take and Cancel. The cursor is a crosshair. - A click picks a candidate and writes nothing yet. The candidate gets its own cyan frame, the selection stays on the object with the variable. - Clicking follows the selection rule. `pickOn` in `src/viewport/pick.ts` uses `pressOn` and only counts objects the dropdown offers. A click on empty space keeps the candidate. - Enter or Take writes through the same handlers as the dropdown. That is one undo step, or none if nothing changes. - Esc, Cancel, a right click in the view or a second click on the button cancel without writing. So do a tab switch, another selection, undo, redo, play and loading a project. - After Take or Cancel the editor goes back to the tab the pick came from. - While the eyedropper runs, the view does not drag, marquee, paint, show handles or open its context menu. Panning and zooming stay. Found on the way: - Started from the Variables tab, the click missed the object. The Scene View is hidden while that tab is open, and the layout skips hidden children. The strip appeared then, the view moved down by 32 px but kept its old height. `Editor.display()` now lays the row out again after showing it. Tests (on melektaus-atx): - unit pick and object-pick: 27 passed, 13 new - gate: 196 files, 2844 tests, CHECK EXIT 0. Two more come from svg-icons, which checks every icon twice. - e2e 57: ALL PASSED, 12 checks, 5 new (57e to 57g) - Counter-checks work. Without the layout fix 57g fails. Picking objects the dropdown does not offer fails 2 tests. Writing on cancel fails 2 more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
42647d309b
commit
ded71a92c9
24 files changed
+777
-34
No files matched your search
@@ -49,6 +49,7 @@ import { GraphEditor } from './graph/GraphEditor';
|
||||
import { Inspector } from './inspector/Inspector';
|
||||
import { valuesTitle, VariablesEditor } from './variables/VariablesEditor';
|
||||
import { valuesKey } from './variables/target';
|
||||
import { pickView } from './objectPick';
|
||||
import { AnimationEditor } from './animation/AnimationEditor';
|
||||
import { TileEditor } from './tile/TileEditor';
|
||||
import { AssetPanel } from './panels/AssetPanel';
|
||||
@@ -506,6 +507,38 @@ export class Editor implements PlayHost {
|
||||
this.showTab('scene');
|
||||
});
|
||||
state.on('mode', () => this.editorRun.invalidate());
|
||||
state.on('pick', () => this.followPick());
|
||||
}
|
||||
|
||||
/** The tab the eyedropper was started from, when it had to leave it for the view it picks in. */
|
||||
private pickReturn: { tab: TabId; doc: DocumentId | null } | null = null;
|
||||
|
||||
/**
|
||||
* Brings up the view the eyedropper picks in (#276) – a field in a Variables tab has none beside
|
||||
* it – and goes back there once it is taken or cancelled. Dropped, it stays: the user went elsewhere.
|
||||
*/
|
||||
private followPick(): void {
|
||||
const pick = this.state.objectPick;
|
||||
if (!pick) {
|
||||
const back = this.pickReturn;
|
||||
this.pickReturn = null;
|
||||
if (!back || this.state.pickEnd === 'drop') return;
|
||||
if (back.doc) this.openDocument(back.doc);
|
||||
else this.showTab(back.tab);
|
||||
return;
|
||||
}
|
||||
if (this.showsPick()) return;
|
||||
this.pickReturn ??= { tab: this.tab, doc: this.documents.active };
|
||||
if (pickView(this.state, pick.holderId) === 'container') this.openDocument(`asset:${pick.holderId}`);
|
||||
else this.showTab('scene');
|
||||
}
|
||||
|
||||
/** Whether the tab showing is the view the running eyedropper picks in. */
|
||||
private showsPick(): boolean {
|
||||
const pick = this.state.objectPick;
|
||||
if (!pick) return false;
|
||||
if (this.tab === 'container') return this.containerEditor.currentAssetId === pick.holderId;
|
||||
return this.tab === 'scene' && pickView(this.state, pick.holderId) === 'scene';
|
||||
}
|
||||
|
||||
/** Ctrl+V lands in whatever the visible tab edits (#240). */
|
||||
@@ -797,10 +830,15 @@ export class Editor implements PlayHost {
|
||||
this.syncTilemapPanel();
|
||||
this.tabs.setActive(strip);
|
||||
this.centre.relayout();
|
||||
// Hidden, the view was left out when its row was laid out – the eyedropper's bar may have
|
||||
// come up over it meanwhile – and its pane may come back at the same size and not relayout.
|
||||
if (tab === 'scene') this.sceneRow.relayout();
|
||||
// Hidden, it skipped every change; its pane may come back at the same size and not relayout.
|
||||
this.gameView.redraw();
|
||||
this.viewport.catchUp();
|
||||
ui().focus.validate();
|
||||
// Picking goes on in its own view only; another tab brought up ends it without writing.
|
||||
if (this.state.objectPick && !this.showsPick()) this.state.endObjectPick('drop');
|
||||
}
|
||||
|
||||
/** The tilemap panel belongs to the scene tab and needs a map to paint; otherwise the view gets its room. */
|
||||
|
||||
Reference in new issue
Block a user