Snap to the grid from the start in every graph tab (#391)
Laying out a graph by hand mostly means lining nodes up, so the magnet was switched on in nearly every session. Every graph tab now starts with it lit: Behavior, State machine, Shader, Particles, Sound FX, Instrument, the song's Routing and the Routing tab. - SnapToggle takes the state it starts in and lights its button to match. GRAPH_SNAPS_AT_FIRST sets it for the toggles and for GraphCanvas alike, so button and canvas cannot disagree. - Curve and Vector Art are no graphs and still start without it. - New hook __gm.graphSnapping(on?) reads every graph tab's magnet, or "mixed" where button and canvas differ, and switches them all. - The e2e harness reads the magnets after each navigate() and then switches them off, as it already sets the zoom transition to 0. Most checks drag a node to an exact spot. e2e 45 does the same itself, because the editor comes up there through the sign-in. - e2e 06 checks that all eight graph tabs started with the magnet on. The checks in 06, 26 and 65 that read it off now say they read what the harness left. Tests: - Unit snap-toggle: 4 tests, 1 new (lit at first, nothing asked of the target before a click). - e2e 06 (melektaus-atx): 150 checks, 1 new. e2e 34: 134 checks. - Gate (melektaus-atx, together with #390): 287 files, 4397 tests. - Pictures looked at: none, the state comes from the hook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e70954115c
commit
fe4e0d9f1a
18 files changed
+104
-25
No files matched your search
@@ -373,6 +373,32 @@ export function uiHooks({ app, state, editor }: HookContext) {
|
||||
if (ms !== undefined) keepGeneralSettings({ zoomTransitionMs: ms });
|
||||
return generalSettings().zoomTransitionMs;
|
||||
},
|
||||
/**
|
||||
* Whether each graph tab's magnet is on (#391); with `on` they are all switched first. The
|
||||
* harness reads them on every load and then switches them off, so a drag lands where it is let go.
|
||||
*/
|
||||
graphSnapping: (on?: boolean) => {
|
||||
const tabs = {
|
||||
logic: [editor.graphEditor.snap, editor.graphEditor.canvas],
|
||||
stateMachine: [editor.stateMachineEditor.snap, editor.stateMachineEditor.canvas],
|
||||
shader: [editor.shaderEditor.snap, editor.shaderEditor.canvas],
|
||||
particles: [editor.particlesEditor.snap, editor.particlesEditor.canvas],
|
||||
soundFx: [editor.soundFxEditor.snap, editor.soundFxEditor.canvas],
|
||||
instrument: [editor.instrumentEditor.snap, editor.instrumentEditor.canvas],
|
||||
song: [editor.songEditor.snap, editor.songEditor.routing],
|
||||
routing: [editor.routingEditor.snap, editor.routingEditor.canvas],
|
||||
} as const;
|
||||
if (on !== undefined) for (const [snap] of Object.values(tabs)) snap.set(on);
|
||||
// The magnet lit and the canvas snapping, or "mixed" where the two disagree.
|
||||
return Object.fromEntries(
|
||||
Object.entries(tabs).map(([tab, [snap, canvas]]) => [
|
||||
tab,
|
||||
snap.button.toggled === canvas.snapEnabled && snap.snapping === canvas.snapEnabled
|
||||
? canvas.snapEnabled
|
||||
: 'mixed',
|
||||
]),
|
||||
);
|
||||
},
|
||||
/** The "Open project" dialog (#183): the projects it lists and the row picked. */
|
||||
projectPicker: () => editor.projectPickerDialog()?.info() ?? null,
|
||||
/** The "Snapshots" dialog (#231): its rows, newest first, the row picked and its name field. */
|
||||
|
||||
Reference in new issue
Block a user