Float a document's tab in a window of its own, and dock it (#371)
The Parametric EQ has a tab of its own since #370, but Play is in the sound FX's tab. A tab that can float keeps both in view. There is one editor per kind, so the kind's pane is lent to the window and given back on Dock, the way fullscreen moves the game view. - A right-click on a document's tab opens a menu with Float and Close. `DocumentTab` passes the press to `TabStrip`'s new `onMenu`. - `FloatWindow` sits on the overlay. Its title bar moves it, its lower right corner sizes it, Dock and the x close it. A press brings it to the front. - `floating.ts` is the pure part: where a window opens, held whole on the screen, sized down to 320 x 200. Nothing of it is remembered. - One window per kind. Another document of that kind opens there and closes the one it had. Its tab, if it had one, leaves the row. - When the row showed the kind, it shows the nearest document whose kind is not in a window, else the scene (`neighbourOf`). - Delete, Copy and Paste go to the window pressed last, and back to the tab showing after a press in the editor (`keyTab`). - Previews tick and redraw for a kind in a window as for the tab showing. Fullscreen hides the windows. Loading a project or signing out closes them. - Only documents float, Scene and Game stay in the row. - Hooks: `floatWindows`, `floatDocument`, `keyTarget`. Tests: - Unit documents: 16 green, 5 new. Counter-check: `neighbourOf` without the window check turns its test red. - e2e 44 (melektaus-atx, after steps 1-12 and 37): ALL PASSED, 505 checks in the chain, 6 new for float, move, size, another texture, keys, Dock and x. - Gate (melektaus-atx): CHECK EXIT 0, 274 files, 4236 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9166d4a56f
commit
76f5097a38
9 files changed
+642
-34
No files matched your search
@@ -157,6 +157,111 @@ export async function documents(t) {
|
||||
await mutate(
|
||||
`__gm.state.project.assets.push(window.__deletedSheet); delete window.__deletedSheet; __gm.state.preview();`,
|
||||
);
|
||||
|
||||
// 44i. A right-click on a tab floats it: the document leaves the row for a window of its own.
|
||||
await evaluate(`__gm.openDocument(${JSON.stringify(`asset:${a.id}`)})`);
|
||||
const tabOfA = await place(`asset:${a.id}`);
|
||||
await click(tabOfA.x + 20, tabOfA.y + tabOfA.h / 2, 'right');
|
||||
const floatEntry = (await json(`__gm.locateAll('Float')`)).find(
|
||||
(p) => p.y > tabOfA.y + tabOfA.h && Math.abs(p.x - tabOfA.x) < 200,
|
||||
);
|
||||
if (floatEntry) await click(floatEntry.x, floatEntry.y);
|
||||
const windows = () => json('__gm.floatWindows()');
|
||||
const floated = await windows();
|
||||
const inWindow = await json('__gm.texture.rect()');
|
||||
const box = floated[0]?.box;
|
||||
check(
|
||||
'Float in a tab’s menu moves the document into a window, the texture in it',
|
||||
!(await docs()).docs.includes(`asset:${a.id}`) &&
|
||||
floated.length === 1 &&
|
||||
floated[0].kind === 'texture' &&
|
||||
floated[0].doc === `asset:${a.id}` &&
|
||||
floated[0].title === a.name &&
|
||||
(await json('__gm.tab()')) === 'scene' &&
|
||||
(await current()) === a.id &&
|
||||
inWindow.x >= box.x &&
|
||||
inWindow.x + inWindow.w <= box.x + box.w &&
|
||||
inWindow.y > box.y &&
|
||||
inWindow.y + inWindow.h <= box.y + box.h,
|
||||
JSON.stringify({ floatEntry, floated, inWindow, docs: await docs() }),
|
||||
);
|
||||
|
||||
// 44j. The title bar moves the window, its corner sizes it, and the texture grows along.
|
||||
await t.drag(floated[0].bar.x, floated[0].bar.y, floated[0].bar.x - 100, floated[0].bar.y - 60);
|
||||
const moved = (await windows())[0];
|
||||
await t.drag(moved.grip.x, moved.grip.y, moved.grip.x + 80, moved.grip.y + 40);
|
||||
const grown = (await windows())[0];
|
||||
const grownRect = await json('__gm.texture.rect()');
|
||||
check(
|
||||
'dragging the title bar moves the window, dragging its corner sizes it',
|
||||
moved.box.x === box.x - 100 &&
|
||||
moved.box.y === box.y - 60 &&
|
||||
grown.box.w === box.w + 80 &&
|
||||
grown.box.h === box.h + 40 &&
|
||||
grown.box.x === moved.box.x &&
|
||||
grownRect.w === inWindow.w + 80,
|
||||
JSON.stringify({ box, moved: moved.box, grown: grown.box, inWindow, grownRect }),
|
||||
);
|
||||
await shot('44-float');
|
||||
|
||||
// 44k. Another texture opened goes into the window: the kind has one editor, so one window.
|
||||
const rowB = await json(`__gm.assetRow(${JSON.stringify(b.id)})`);
|
||||
await doubleClick(rowB.x, rowB.y);
|
||||
const other = await windows();
|
||||
check(
|
||||
'opening another texture shows it in the window, not in a tab',
|
||||
other.length === 1 &&
|
||||
other[0].doc === `asset:${b.id}` &&
|
||||
other[0].title === b.name &&
|
||||
!(await docs()).docs.includes(`asset:${b.id}`) &&
|
||||
(await current()) === b.id,
|
||||
JSON.stringify({ other, docs: await docs() }),
|
||||
);
|
||||
|
||||
// 44l. Delete, Copy and Paste go where the last press went.
|
||||
await click(other[0].bar.x, other[0].bar.y);
|
||||
const toWindow = await json('__gm.keyTarget()');
|
||||
const scene = (await json('__gm.tabRow()')).shown.find((p) => p.tab === 'scene');
|
||||
await click((scene.x + scene.right) / 2, scene.y + scene.h / 2);
|
||||
const toTabs = await json('__gm.keyTarget()');
|
||||
check(
|
||||
'keys go to the window after a press in it, and to the tab after a press in the editor',
|
||||
toWindow === 'texture' && toTabs === 'scene',
|
||||
JSON.stringify({ toWindow, toTabs }),
|
||||
);
|
||||
|
||||
// 44m. Dock puts the document back into the row, showing, with its pane below the row.
|
||||
await click(other[0].dock.x, other[0].dock.y);
|
||||
const docked = await docs();
|
||||
const dockedRect = await json('__gm.texture.rect()');
|
||||
check(
|
||||
'Dock brings the document back as a tab, showing',
|
||||
(await windows()).length === 0 &&
|
||||
docked.active === `asset:${b.id}` &&
|
||||
(await json('__gm.tab()')) === 'texture' &&
|
||||
(await current()) === b.id &&
|
||||
dockedRect.w > 0 &&
|
||||
dockedRect.h > 0,
|
||||
JSON.stringify({ docked, dockedRect }),
|
||||
);
|
||||
|
||||
// 44n. The window's × closes the document, and the kind shows in the tabs again.
|
||||
await evaluate(`__gm.floatDocument(${JSON.stringify(`asset:${b.id}`)})`);
|
||||
const again = await windows();
|
||||
await click(again[0].close.x, again[0].close.y);
|
||||
const closed = { windows: await windows(), docs: await docs() };
|
||||
await showTab('texture');
|
||||
check(
|
||||
'the × closes the window and its document; the kind opens in a tab again',
|
||||
closed.windows.length === 0 &&
|
||||
!closed.docs.docs.includes(`asset:${b.id}`) &&
|
||||
(await json('__gm.tab()')) === 'texture' &&
|
||||
(await json('__gm.texture.rect()')).w > 0,
|
||||
JSON.stringify({ again, closed, tab: await json('__gm.tab()') }),
|
||||
);
|
||||
for (const doc of (await docs()).docs) await evaluate(`__gm.closeDocument(${JSON.stringify(doc)})`);
|
||||
await showTab('scene');
|
||||
|
||||
await mutate(`
|
||||
for (const { id, was } of ${JSON.stringify([a, b])}) __gm.state.project.assets.find((x) => x.id === id).name = was;
|
||||
__gm.state.preview();
|
||||
|
||||
Reference in new issue
Block a user