Round 12 of the clean-up. Duplicate code had grown from 33 clones (249 lines) after round 11 to 140 clones (1263 lines), almost all of it in the panels and faces of the sound FX devices (#379 to #401). It is down to 57 clones (416 lines) now, and src is 816 lines shorter. - deviceParts.ts holds what the device panels built by hand: the head, rows of knobs, the screen style and the row layout for groups of knobs. Twelve panels use it. panel.knobs stays because the debug hooks read it. - DeviceFace is the base of the twelve faces. It finds the node and does wired, preview, commit, set, hide, reload and audition. compressorWired lives there as paramWired. - TextPool replaces ten copies of "make texts as needed, hide the rest" in the wave and video tabs, the rulers, the piano roll and the song and composition timelines. clipStrip.ts is the clip label strip the wave and video tabs share. - core/util/bytes.ts has the concat that ogg, matroska and avcColour each wrote out. - Dead code is gone: clear on the video players (never called since #402), posterFileOf and videoTimeAt (only tests called them) and easeOut (the same as glide(t, 3)). Values only used in their own file lose their export. - Comments over 125 columns are wrapped, and comments that told the history ("as before", "used to") say what is, in src and in the e2e modules. - Left alone on purpose: AnimationEditor and CompositionEditor share only the play button, and the curve panels are built differently. - Chip now places its boxes through put, which rounds. They were whole numbers already. The three row layouts are byte-identical before and after. - README lists the video and composition assets and the Videos and Compositions pages. Tests: - Gate (melektaus-atx): CHECK EXIT 0, 313 files, 4835 tests. - e2e 25, 34, 64, 65, 66, 69 (melektaus-atx): ALL PASSED, 330 checks. - TextPool without keeping its texts and framesToRoom without making room both go red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.4 KiB
TypeScript
65 lines
2.4 KiB
TypeScript
import { masterRoutingProblems } from '../../core/music/projectRouting';
|
|
import { ROUTING_ID } from '../../core/model/Project';
|
|
import { Button, Label, Spacer, VStack } from '../../ui';
|
|
import { GraphCanvas } from '../graph/GraphCanvas';
|
|
import { GRAPH_SNAPS_AT_FIRST, SnapToggle } from '../graph/SnapToggle';
|
|
import type { EditorState } from '../state';
|
|
import { TabHeader } from '../TabHeader';
|
|
|
|
const INFO_WIDTH = 220;
|
|
|
|
/**
|
|
* The Master routing tab (#351), one per project: a node per sound, instrument, pattern, song, video
|
|
* with sound, composition and bus and the master, the links between them where each one goes.
|
|
* Edited as the routing of a song is (#350); a click on a node shows its asset in the inspector, a
|
|
* double click opens it.
|
|
*/
|
|
export class RoutingEditor extends VStack {
|
|
readonly canvas: GraphCanvas;
|
|
readonly fitButton: Button;
|
|
readonly snap: SnapToggle;
|
|
private readonly info = new Label('', { style: 'small', align: 'right' });
|
|
|
|
constructor(private readonly state: EditorState) {
|
|
super();
|
|
this.canvas = new GraphCanvas(state, 'routing');
|
|
this.snap = new SnapToggle(() => this.canvas, GRAPH_SNAPS_AT_FIRST);
|
|
this.fitButton = new Button('Fit', { onClick: () => this.canvas.fit() });
|
|
this.info.minWidth = INFO_WIDTH;
|
|
const header = new TabHeader();
|
|
for (const widget of this.snap.widgets) header.add(widget);
|
|
header.add(this.fitButton);
|
|
header.add(new Spacer(), 1);
|
|
header.add(this.info);
|
|
this.add(header);
|
|
this.add(this.canvas, 1);
|
|
state.on('project', () => this.refresh());
|
|
state.on('load', () => this.close());
|
|
}
|
|
|
|
/** Shows the routing of the project; framed the first time, as it was left after that. */
|
|
open(): void {
|
|
this.canvas.show(ROUTING_ID);
|
|
this.refresh();
|
|
}
|
|
|
|
/** The tab is closed: opened again, the routing starts from a fitted view. */
|
|
close(): void {
|
|
this.canvas.show('');
|
|
this.refresh();
|
|
}
|
|
|
|
/** The readout: how many links, and how many nodes go nowhere and are never heard. */
|
|
get shownInfo(): string {
|
|
return this.info.text;
|
|
}
|
|
|
|
private refresh(): void {
|
|
if (this.canvas.currentAssetId !== ROUTING_ID) return this.info.setText('');
|
|
const graph = this.state.project.routing;
|
|
const silent = Object.keys(masterRoutingProblems(graph)).length;
|
|
const links = `${graph.edges.length} link${graph.edges.length === 1 ? '' : 's'}`;
|
|
this.info.setText(silent > 0 ? `${links} · ${silent} going nowhere` : links);
|
|
}
|
|
}
|