Split wiring, drags and the frame layer out of GraphCanvas (#215)
GraphCanvas had grown to 1406 lines. Wiring, dragging and the frame
views each carry their own state, so they now live in their own
classes behind a narrow host interface. Behaviour is unchanged.
- GraphCanvasHost is what the new classes see of the canvas.
- Wiring owns dragging a pin, the palette on a drop into empty space
and "Make transition".
- GraphDrags owns moving nodes and frames, including snapping.
- AnnotationLayer holds the frame views. The test hooks stay on the
canvas and read the views through the layer.
- BeadClock moves into beads.ts and can now be tested without a
browser.
- The canvas builds host, wiring and drags in its constructor because
state is a parameter property and not set during field init.
- GraphCanvas is down to 1019 lines.
Tests:
- ./check.sh: 145 files, 2192 tests, CHECK EXIT 0 (+2 for BeadClock)
- e2e 1-28,31,36: ALL PASSED, 932 checks
- New e2e check in 36k: a frame caught by the rubber band is also
drawn as selected. No check covered that before. Against a bent
build it fails with selected: false.
- Counter-checks for drop target, snapping and beads fail exactly
the expected checks.
- Editor check sum is now 1314 (CI measured 1313 at 487b3aa).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e31db3df1d
commit
b830f9c747
9 files changed
+631
-454
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import type { AddNodeCommand } from '../../core/commands/graphCommands';
|
||||
import type { GraphAsset } from '../../core/model/Asset';
|
||||
import type { Box } from '../framing';
|
||||
import type { EditorState } from '../state';
|
||||
import type { NodeView } from './NodeView';
|
||||
import type { PaletteEntry } from './paletteEntries';
|
||||
import type { Point } from './transitions';
|
||||
|
||||
/** What the graph canvas lends the gestures that work inside it. */
|
||||
export interface GraphCanvasHost {
|
||||
readonly state: EditorState;
|
||||
/** The asset on the canvas; empty when there is none. */
|
||||
assetId(): string;
|
||||
asset(): GraphAsset | null;
|
||||
views(): ReadonlyMap<string, NodeView>;
|
||||
/** Views in stacking order, topmost first – a node drawn over another one wins the pointer. */
|
||||
topDownViews(): Iterable<NodeView>;
|
||||
nodeUnder(global: Point): string | null;
|
||||
/** Each node as the rectangle it is actually drawn as. */
|
||||
nodeBoxes(): Box[];
|
||||
/** The graph point under a global pointer position. */
|
||||
toGraph(global: Point): Point;
|
||||
/** Screen pixels per graph unit. */
|
||||
zoom(): number;
|
||||
snapping(): boolean;
|
||||
/** What the palette offers for this graph. */
|
||||
entries(): PaletteEntry[];
|
||||
/** The command that adds a node from the palette at a graph point. */
|
||||
newNode(entry: PaletteEntry, at: Point): AddNodeCommand;
|
||||
redraw(): void;
|
||||
}
|
||||
Reference in new issue
Block a user