The Container tab reuses SceneViewport against any object holder, so a container template is edited exactly like a scene. Right-click no longer changes the selection, which previously made nesting impossible: opening the menu on a container loaded it, and "Place in container" then targeted itself. Template edits (move, rename, override) now reach already-placed instances per slot, through a shared templateSync used by both the apply path and the plain object commands. Copies the user has touched keep their own value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
import { same } from '../lib/harness.mjs';
|
||
|
||
/**
|
||
* Hierarchy folding. A freshly opened scene is fully collapsed, so only its top-level objects
|
||
* are listed (o4/oc1 hang under o1, oc2 under o2). The chevron folds a row open and shut
|
||
* without touching the selection, and selecting a nested object unfolds the way down to it.
|
||
*/
|
||
export async function hierarchy(t) {
|
||
const { check, sleep, evaluate, json, click, select, state, shot } = t;
|
||
const rowIds = () => json('__gm.hierarchyOrder()');
|
||
const rows = async () => JSON.stringify(await rowIds());
|
||
const selectionBefore = (await state()).selection;
|
||
|
||
check(
|
||
'hierarchy starts collapsed – only top-level objects are listed',
|
||
same(await rowIds(), ['o1', 'o2', 'o3', 'o5']),
|
||
await rows(),
|
||
);
|
||
check('a leaf row offers no chevron', (await evaluate(`__gm.hierarchyChevron('o3')`)) === null);
|
||
const chevron = await json(`__gm.hierarchyChevron('o2')`);
|
||
await click(chevron.x, chevron.y);
|
||
check(
|
||
'clicking the chevron unfolds the row, leaving the selection alone',
|
||
same(await rowIds(), ['o1', 'o2', 'oc2', 'o3', 'o5']) && same((await state()).selection, selectionBefore),
|
||
await rows(),
|
||
);
|
||
await shot('01a-hierarchy-unfolded');
|
||
await click(chevron.x, chevron.y);
|
||
check(
|
||
'clicking it again folds the subtree away',
|
||
same(await rowIds(), ['o1', 'o2', 'o3', 'o5']),
|
||
await rows(),
|
||
);
|
||
await select({ kind: 'object', holderId: 'scene1', objectId: 'oc1' });
|
||
await sleep(150);
|
||
check(
|
||
'selecting a nested object unfolds its ancestors',
|
||
same(await rowIds(), ['o1', 'o4', 'oc1', 'o2', 'o3', 'o5']),
|
||
await rows(),
|
||
);
|
||
await evaluate('__gm.state.select(null); __gm.hierarchyCollapseAll()');
|
||
await sleep(150);
|
||
check('Collapse all folds everything back', same(await rowIds(), ['o1', 'o2', 'o3', 'o5']), await rows());
|
||
}
|