Open the add menu with a right-click in the asset panel (#244)
New assets could only be added through the + button. A right-click on a category heading or on the empty space below the rows now opens the same menu at the pointer. - ListView gets the callback onListMenu. It fires on a right-click on empty space or on a heading. Only the asset panel has headings, so other lists are not affected. - AssetPanel opens its + menu from there. - A right-click on a heading does not fold or unfold the category. A right-click on empty space clears the selection like a left-click. - A right-click on an asset still opens the menu of that asset. - The empty list now says "No assets - press + or right-click". Tests: - ./check.sh: 178 files, 2573 tests, CHECK EXIT 0 - e2e 1-4: ALL PASSED, 134 checks - 3 new checks in e2e 04 with real right-clicks: menu on the "Scenes" heading (21 types, heading stays folded), menu on empty space, and "Behavior" from that menu creates one, undone again. - Counter-probe: without the menu both right-click checks fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38f009e035
commit
e0b471c354
4 files changed
+58
-3
No files matched your search
@@ -32,6 +32,8 @@ export async function assets(t) {
|
||||
await shot('11-context-menu');
|
||||
await press('Escape');
|
||||
|
||||
await addMenuOnRightClick(t);
|
||||
|
||||
// 4b. Drag the Crate asset from the panel into the scene view. Driven step by step rather than
|
||||
// with `drag()`, because the preview only exists while the button is still down.
|
||||
const from = await json("__gm.assetRow('crate')");
|
||||
@@ -443,3 +445,50 @@ export async function assets(t) {
|
||||
JSON.stringify({ first, typeOfFirst, rowAt, iconAt, ink, typeWords }),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4a-ii. Where no menu of its own opens – on a group heading or on the empty space below the rows –
|
||||
* a right-click brings up the + menu (#244). The heading stays folded as it was.
|
||||
*/
|
||||
async function addMenuOnRightClick(t) {
|
||||
const { check, json, shot, click, clickText, press, undo, showTab } = t;
|
||||
const addRows = (rows) =>
|
||||
Array.isArray(rows) && rows.filter(Boolean).length === 21 && rows.includes('Sprite');
|
||||
const heading = await json("__gm.assetRowShown('group:scene')");
|
||||
const sceneFolded = async () =>
|
||||
!(await json('__gm.assetGroups()')).find((g) => g.type === 'scene').expanded;
|
||||
const foldedBefore = await sceneFolded();
|
||||
await click(heading.x, heading.y, 'right');
|
||||
const onHeading = await json('__gm.menuRows()');
|
||||
check(
|
||||
'a right-click on a group heading opens the + menu and leaves the group as it was',
|
||||
addRows(onHeading) && (await sceneFolded()) === foldedBefore,
|
||||
JSON.stringify({ onHeading, foldedBefore }),
|
||||
);
|
||||
await press('Escape');
|
||||
const groups = await json('__gm.assetGroups()');
|
||||
const lastGroup = groups.at(-1);
|
||||
const lastShown = await json(
|
||||
`__gm.assetRowShown(${JSON.stringify(lastGroup.expanded ? lastGroup.ids.at(-1) : `group:${lastGroup.type}`)})`,
|
||||
);
|
||||
const panel = await json('__gm.assetsRect()');
|
||||
const empty = { x: panel.x + panel.w / 2, y: panel.y + panel.h - 12 };
|
||||
await click(empty.x, empty.y, 'right');
|
||||
const onEmpty = await json('__gm.menuRows()');
|
||||
check(
|
||||
'a right-click on the empty space below the rows opens the + menu',
|
||||
empty.y > lastShown.y + 20 && addRows(onEmpty),
|
||||
JSON.stringify({ empty, lastShown, onEmpty }),
|
||||
);
|
||||
await shot('11c-add-menu-on-right-click');
|
||||
const before = (await json('__gm.state.project.assets')).length;
|
||||
await clickText('Behavior');
|
||||
const fromMenu = await json('__gm.state.project.assets.at(-1)');
|
||||
check(
|
||||
'an entry of that menu creates the asset like the + button does',
|
||||
(await json('__gm.state.project.assets')).length === before + 1 && fromMenu.type === 'behavior',
|
||||
JSON.stringify(fromMenu && { type: fromMenu.type, name: fromMenu.name }),
|
||||
);
|
||||
await undo();
|
||||
await showTab('scene');
|
||||
}
|
||||
Reference in new issue
Block a user