Tabs are open documents: Scene, Game and Plugins stay as fixed tabs, every other asset opens in its own tab (double click or Enter in the asset panel, on creation, from the list button), several assets of one kind can be open at once, a tab is labelled with its kind dimmed before the name, cut at 160 px and renamed with its asset, closes with its x or a middle click and goes away when its asset is deleted; a tab always shows its own document instead of following the selection, the picker in the tab head is gone, zoom and scroll are kept per document for the session and dropped on close, a double click on a call node stays in the same tab with breadcrumbs per tab; one editor per kind is switched between documents, the placement rules live in the pure module documents.ts, and the test hook showTab stays as a compatibility path; new e2e module 44 documents (#171)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f546c0e08
commit
cc285af10a
33 files changed
+895
-225
No files matched your search
@@ -128,6 +128,11 @@ export const TAB_LABELS = {
|
||||
* nothing and took the whole suite down with it.
|
||||
*/
|
||||
export async function openTab(t, tab) {
|
||||
// A kind of document has no tab of its own since #171; the hook shows the one the selection is about.
|
||||
if (DOCUMENT_KINDS.includes(tab)) {
|
||||
await t.evaluate(`__gm.showTab(${JSON.stringify(tab)})`);
|
||||
return;
|
||||
}
|
||||
const label = TAB_LABELS[tab];
|
||||
const row = await t.json('__gm.tabRow()');
|
||||
if (row.hidden.includes(tab)) {
|
||||
@@ -148,6 +153,42 @@ export async function openTab(t, tab) {
|
||||
else await t.clickText(label);
|
||||
}
|
||||
|
||||
const DOCUMENT_KINDS = [
|
||||
'graph',
|
||||
'statemachine',
|
||||
'shader',
|
||||
'particles',
|
||||
'texture',
|
||||
'animation',
|
||||
'tile',
|
||||
'container',
|
||||
'list',
|
||||
];
|
||||
|
||||
/**
|
||||
* Clicks the tab of an open document (`asset:<id>` or `list`), through the `»` menu when the row
|
||||
* hides it. The press lands left of the ×, on the name.
|
||||
*/
|
||||
export async function clickDocumentTab(t, doc) {
|
||||
const row = await t.json('__gm.tabRow()');
|
||||
const entry = row.shown.find((e) => e.tab === doc);
|
||||
if (entry) {
|
||||
await t.click(entry.x + (entry.close.x - entry.x) / 2, entry.y + entry.h / 2);
|
||||
return;
|
||||
}
|
||||
if (!row.hidden.includes(doc)) throw new Error(`no tab for ${doc}`);
|
||||
const label = await t.json(`(() => {
|
||||
const id = ${JSON.stringify(doc)};
|
||||
if (id === 'list') return null;
|
||||
const asset = __gm.state.project.assets.find((a) => 'asset:' + a.id === id);
|
||||
return asset ? asset.name : null;
|
||||
})()`);
|
||||
await t.clickText('»');
|
||||
const item = (await t.json('__gm.menuRows()')).find((r) => r && r.endsWith(` · ${label}`));
|
||||
const at = await t.locate(item, true);
|
||||
await t.click(at.x, at.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks an asset type from the already-open `+` menu. Since #43 the menu may grow to the height of
|
||||
* the canvas, so on this window every type is usually on screen at once; the scroll stays in as
|
||||
|
||||
Reference in new issue
Block a user