Share the parts the sound devices and timelines repeated (#85)
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>
This commit is contained in:
1 parent
df6dbe97c5
commit
0701fe3856
94 files changed
+1602
-2380
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { Container } from 'pixi.js';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { TextPool } from '../../src/ui/textPool';
|
||||
|
||||
describe('a pool of texts', () => {
|
||||
it('makes a text for each wanted string, in their order', () => {
|
||||
const layer = new Container();
|
||||
const shown = new TextPool(layer).show(['0', '1', '2']);
|
||||
expect(shown.map((t) => t.text)).toEqual(['0', '1', '2']);
|
||||
expect(layer.children).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('keeps a text on the string it shows, so a pan sets only the new one', () => {
|
||||
const pool = new TextPool(new Container());
|
||||
const [, one, two] = pool.show(['0', '1', '2']);
|
||||
const before = pool.changes;
|
||||
const shown = pool.show(['1', '2', '3']);
|
||||
expect(shown[0]).toBe(one);
|
||||
expect(shown[1]).toBe(two);
|
||||
expect(shown.map((t) => t.text)).toEqual(['1', '2', '3']);
|
||||
expect(pool.changes - before).toBe(1);
|
||||
});
|
||||
|
||||
it('hides the texts not wanted and makes no more than it needs', () => {
|
||||
const layer = new Container();
|
||||
const pool = new TextPool(layer);
|
||||
pool.show(['a', 'b', 'c']);
|
||||
const [kept] = pool.show(['b']);
|
||||
expect(kept!.text).toBe('b');
|
||||
expect(layer.children.filter((t) => t.visible)).toEqual([kept]);
|
||||
pool.show(['x', 'y', 'z']);
|
||||
expect(layer.children).toHaveLength(3);
|
||||
expect(layer.children.every((t) => t.visible)).toBe(true);
|
||||
});
|
||||
|
||||
it('gives a string wanted twice two texts', () => {
|
||||
const pool = new TextPool(new Container());
|
||||
pool.show(['…', '…']);
|
||||
const shown = pool.show(['…', '…']);
|
||||
expect(new Set(shown).size).toBe(2);
|
||||
expect(pool.changes).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user