Snap is a magnet button in every graph and vector art tab (#194)
The snap toggle was a checkbox with the word "Snap" next to Fit, and the vector art tab had its own "Grid" button for the same idea. Both now share one square icon button, so snapping looks and works the same wherever it exists. - SnapToggle is a square toggle button with a magnet icon and no text. It lights up blue when snapping is on, like the other toggle buttons. - The magnet is drawn with cubic curves instead of arcs, because the Pixi SVG parser draws arcs as jagged edges. - The vector art tab drops its Grid button and uses the same SnapToggle. It still snaps to 8 px, the graph tabs to 24 px. - SnapToggle accepts anything with setSnapping(on). The vector art canvas method is renamed from setSnap to setSnapping for that. - Every tab exposes the button as __gm.<tab>.snapButton(). Modules 06, 26 and 36 click through that hook instead of the label "Snap" plus 30 px. Tests: - ./check.sh: 129 files, 1903 tests (was 128 / 1897) - 3 new tests in tests/editor/snap-toggle.test.ts, 3 in the icon tests - GM_STEPS=1-6,26,36,47 fresh: ALL PASSED, 346 checks - GM_STEPS=47: ALL PASSED, 32 checks (was 29) - Counter-checks: toggle not switching its target fails 2 unit tests, the canvas ignoring the switch fails module 47 - Check total 1188 in README and wiki is computed (1184 + 4), the full run is left to CI Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad62a0f525
commit
90627ccf47
17 files changed
+181
-43
No files matched your search
@@ -87,6 +87,7 @@ export async function vectorArt(t) {
|
||||
shot,
|
||||
showTab,
|
||||
typeText,
|
||||
undo,
|
||||
} = t;
|
||||
const Y = LANES.vectorArt;
|
||||
|
||||
@@ -225,6 +226,29 @@ export async function vectorArt(t) {
|
||||
JSON.stringify(moved),
|
||||
);
|
||||
|
||||
// The magnet is the graph's (#194): the tab has no Grid button of its own any more, and with it
|
||||
// on a ragged drop lands on the 8 px grid. Undone, so the point is back where the next steps expect it.
|
||||
const magnet = await json('__gm.vectorArt.snapButton()');
|
||||
check(
|
||||
'the tab carries the magnet in place of a Grid button',
|
||||
magnet.w === magnet.h && !magnet.toggled && (await json(`__gm.locate('Grid')`)) === null,
|
||||
JSON.stringify(magnet),
|
||||
);
|
||||
await click(magnet.x, magnet.y);
|
||||
const snapFrom = await json(`__gm.vectorArt.pointAt(180, 40)`);
|
||||
const snapTo = await json(`__gm.vectorArt.pointAt(187, 45)`);
|
||||
await drag(snapFrom.x, snapFrom.y, snapTo.x, snapTo.y);
|
||||
const onGrid = (await json("__gm.vectorArt.shapes('va-art')")).at(-1).rings[0].points[1];
|
||||
check(
|
||||
'with the magnet on, a dragged point lands on the grid',
|
||||
(await json('__gm.vectorArt.snapping()')) === true && onGrid.x === 184 && onGrid.y === 48,
|
||||
JSON.stringify(onGrid),
|
||||
);
|
||||
await shot('47-magnet');
|
||||
await undo();
|
||||
await click(magnet.x, magnet.y);
|
||||
check('the magnet switches snapping off again', (await json('__gm.vectorArt.snapping()')) === false);
|
||||
|
||||
const pulled = await json(`__gm.vectorArt.pointAt(180, 40)`);
|
||||
await click(pulled.x, pulled.y, 'left', { alt: true });
|
||||
const smooth = (await json("__gm.vectorArt.shapes('va-art')")).at(-1).rings[0].points[1];
|
||||
|
||||
Reference in new issue
Block a user