Two things came up on the new tab. Floated and sized down, it spilled its knobs out of its window, and sized up it left the window empty. Auto-gain lifted far too much: it brought 0 dB back to 0 dB, which at -40 dB, 4:1 and knee 6 is +28.1 dB, so a sound at -24 dB came out at -6 dB. And as a knob from 0 to 1 it blended between makeup and auto-gain, so at 1 the makeup knob did nothing. Layout: - The knobs stay on the bottom line, centred, with the help line above them. - The levels fill the height left above. The curve is a square at their right, centred up and down. It grows with the tab from 180 to 360 px and takes no more than 40 % of its width (picturesLayout). - A floated window cannot be sized below what its pane needs. A pane says so in its minWidth and minHeight, and the Compressor's is every knob and the smallest pictures. Other panes keep 320 x 200. - A pane put into an open window that is too small grows the window. Auto-gain, as decided in #378: - A Compressor's auto-gain gives back what it takes from a sound at -18 dB, so that one comes out as loud as it went in. At the numbers above that is +14.6 dB. - Auto-gain is a switch on the Compressor, the Limiter and the Saturation alike, a setting and no longer an input. The makeup or output is added on top of it instead of being blended with it. - A project from before reads a number as on above 0. Nodes never set keep their defaults: off on the Compressor, on on the other two. - The tab shows the switch at the right of the knobs, with the dB it gives below it. With it on, the curve has a line at -18 dB from the curve up to the diagonal. - Every level reading keeps the gain of its time. Before, the whole picture was read by the current makeup, so after a change the tinting of the last seconds was wrong or missing. Findings: - My first e2e run of the layout clicked Dock where it was before the window was sized up, so the window stayed open and the next check went red. The check reads the button again. Tests: - Gate (melektaus-atx): 282 files, 4344 tests (6 new) - e2e 34 (melektaus-atx): ALL PASSED, 118 checks (2 new) - Offline in Chrome: a sine at -18 dB through -24 dB and 4:1 came out at -17.92 dB with auto-gain on and -22.42 dB with it off. - Counter-checks: the curve set at the top instead of the middle, and every reading read at a gain of 0, each fail exactly their test. - Looked at the window in screenshots: at its least every knob and the switch show. At 1280 x 797 the levels fill the height, the curve is centred at the right and the knobs are at the bottom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
5.0 KiB
TypeScript
120 lines
5.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import { closeDocument, neighbourOf, openDocument, replaceDocument } from '../../src/editor/documents';
|
||
import {
|
||
leastBox,
|
||
MIN_WINDOW_HEIGHT,
|
||
MIN_WINDOW_WIDTH,
|
||
onScreen,
|
||
openingBox,
|
||
sized,
|
||
} from '../../src/editor/floating';
|
||
import { tabRowLayout } from '../../src/editor/tabRow';
|
||
|
||
const row = (docs: string[], active: string | null) => ({ docs, active });
|
||
|
||
describe('open documents', () => {
|
||
it('puts a new document right of the one showing', () => {
|
||
expect(openDocument(row(['a', 'b', 'c'], 'a'), 'x')).toEqual(row(['a', 'x', 'b', 'c'], 'x'));
|
||
});
|
||
|
||
it('puts it last while a fixed tab is showing', () => {
|
||
expect(openDocument(row(['a', 'b'], null), 'x')).toEqual(row(['a', 'b', 'x'], 'x'));
|
||
expect(openDocument(row([], null), 'x')).toEqual(row(['x'], 'x'));
|
||
});
|
||
|
||
it('only brings an open document up – one tab per document', () => {
|
||
expect(openDocument(row(['a', 'b', 'c'], 'c'), 'a')).toEqual(row(['a', 'b', 'c'], 'a'));
|
||
});
|
||
|
||
it('shows the left neighbour after the one showing closes', () => {
|
||
expect(closeDocument(row(['a', 'b', 'c'], 'b'), 'b')).toEqual(row(['a', 'c'], 'a'));
|
||
});
|
||
|
||
it('shows the right one when the first closes, and nothing when the last goes', () => {
|
||
expect(closeDocument(row(['a', 'b'], 'a'), 'a')).toEqual(row(['b'], 'b'));
|
||
expect(closeDocument(row(['a'], 'a'), 'a')).toEqual(row([], null));
|
||
});
|
||
|
||
it('keeps what is showing when another tab closes', () => {
|
||
expect(closeDocument(row(['a', 'b', 'c'], 'c'), 'a')).toEqual(row(['b', 'c'], 'c'));
|
||
expect(closeDocument(row(['a', 'b'], null), 'b')).toEqual(row(['a'], null));
|
||
});
|
||
|
||
it('ignores a document that is not open', () => {
|
||
const before = row(['a'], 'a');
|
||
expect(closeDocument(before, 'x')).toBe(before);
|
||
});
|
||
|
||
it('lets a tab go on to another document in its place', () => {
|
||
expect(replaceDocument(row(['a', 'b', 'c'], 'b'), 'b', 'x')).toEqual(row(['a', 'x', 'c'], 'x'));
|
||
});
|
||
|
||
it('drops the other tab of a document it goes on to', () => {
|
||
expect(replaceDocument(row(['a', 'b', 'c'], 'a'), 'a', 'c')).toEqual(row(['c', 'b'], 'c'));
|
||
});
|
||
|
||
it('leaves the row alone for a tab that is not open', () => {
|
||
const before = row(['a'], 'a');
|
||
expect(replaceDocument(before, 'x', 'y')).toBe(before);
|
||
expect(replaceDocument(before, 'a', 'a')).toBe(before);
|
||
});
|
||
});
|
||
|
||
describe('what shows when a document goes to a window (#371)', () => {
|
||
const all = () => true;
|
||
|
||
it('picks the left neighbour, else the right one, else none', () => {
|
||
expect(neighbourOf(['a', 'c'], 1, all)).toBe('a');
|
||
expect(neighbourOf(['b', 'c'], 0, all)).toBe('b');
|
||
expect(neighbourOf([], 0, all)).toBeNull();
|
||
});
|
||
|
||
it('passes over documents whose kind is in a window', () => {
|
||
const tabs = (doc: string) => !doc.startsWith('fx');
|
||
expect(neighbourOf(['a', 'fx1', 'fx2', 'b'], 3, tabs)).toBe('a');
|
||
expect(neighbourOf(['fx1', 'fx2', 'b'], 1, tabs)).toBe('b');
|
||
expect(neighbourOf(['fx1', 'fx2'], 1, tabs)).toBeNull();
|
||
});
|
||
});
|
||
|
||
describe('a tab in a window (#371)', () => {
|
||
it('opens in the middle of the screen, every further window a step lower right', () => {
|
||
expect(openingBox(1280, 800, 0)).toEqual({ x: 320, y: 160, w: 640, h: 480 });
|
||
expect(openingBox(1280, 800, 2)).toEqual({ x: 368, y: 208, w: 640, h: 480 });
|
||
});
|
||
|
||
it('is held whole on the screen when it is moved past an edge', () => {
|
||
expect(onScreen({ x: 900, y: -40, w: 640, h: 480 }, 1280, 800)).toEqual({ x: 640, y: 0, w: 640, h: 480 });
|
||
expect(onScreen({ x: 100, y: 100, w: 640, h: 480 }, 500, 400)).toEqual({ x: 0, y: 0, w: 500, h: 400 });
|
||
});
|
||
|
||
it('is sized from its lower right corner, down to a floor and out to the screen’s edge', () => {
|
||
const box = { x: 600, y: 300, w: 400, h: 300 };
|
||
expect(sized(box, 100, 50, 1280, 800)).toEqual({ ...box, w: 500, h: 350 });
|
||
expect(sized(box, -500, -500, 1280, 800)).toEqual({ ...box, w: MIN_WINDOW_WIDTH, h: MIN_WINDOW_HEIGHT });
|
||
expect(sized(box, 900, 900, 1280, 800)).toEqual({ ...box, w: 680, h: 500 });
|
||
});
|
||
|
||
it('is held at the least its pane needs, but never larger than the screen (#378)', () => {
|
||
const least = leastBox(700.4, 450);
|
||
expect(least).toEqual({ w: 701, h: 450 });
|
||
expect(leastBox(100, 100)).toEqual({ w: MIN_WINDOW_WIDTH, h: MIN_WINDOW_HEIGHT });
|
||
const box = { x: 100, y: 100, w: 800, h: 600 };
|
||
expect(sized(box, -500, -500, 1280, 800, least)).toEqual({ ...box, w: 701, h: 450 });
|
||
expect(onScreen({ ...box, w: 400, h: 300 }, 1280, 800, least)).toEqual({ ...box, w: 701, h: 450 });
|
||
expect(onScreen({ ...box, w: 400, h: 300 }, 600, 400, least)).toEqual({ x: 0, y: 0, w: 600, h: 400 });
|
||
});
|
||
});
|
||
|
||
describe('tab row without an active tab', () => {
|
||
it('fills the row in order when a kind with no document is showing', () => {
|
||
const tabs = [
|
||
{ key: 'a', width: 50 },
|
||
{ key: 'b', width: 50 },
|
||
{ key: 'c', width: 50 },
|
||
];
|
||
const layout = tabRowLayout({ tabs, available: 132, gap: 2, overflowWidth: 28, active: null });
|
||
expect(layout).toEqual({ shown: ['a', 'b'], hidden: ['c'] });
|
||
});
|
||
});
|