Give the three asset tabs one base, and move the viewports into the editor
src/viewport/ held three classes only src/editor/ ever used, and framing.ts sat under graph/ although the scene view wants the same bounds sum. The graph, the texture and the container tab repeated the same header, subscription and disposal code with two silent divergences: the graph tab said "nothing shown" with null instead of '', and the texture tab refell back to the first asset on a selection change but not on a project event. These arrive together because GraphCanvas ties them: it reads framing from its new home, hands its fold marks to folding.ts, and its '' change is what GraphEditor must agree with. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a2f2f8465c
commit
11981b40d0
15 files changed
+408
-425
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { type Box, boxesInBand, frameBoxes } from '../../src/editor/graph/framing';
|
||||
import { boundsOf, type Box, boxesInBand, frameBoxes } from '../../src/editor/framing';
|
||||
|
||||
const LIMITS = { min: 0.25, max: 2.5 };
|
||||
|
||||
@@ -83,3 +83,29 @@ describe('fit', () => {
|
||||
expect(f).toEqual({ zoom: 1, panX: 100, panY: 50 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('boundsOf', () => {
|
||||
it('encloses every box', () => {
|
||||
const boxes: Box[] = [
|
||||
{ id: 'a', x: 10, y: 20, w: 100, h: 60 },
|
||||
{ id: 'b', x: -40, y: 5, w: 20, h: 10 },
|
||||
];
|
||||
expect(boundsOf(boxes)).toEqual({ minX: -40, minY: 5, maxX: 110, maxY: 80 });
|
||||
});
|
||||
|
||||
it('reports nothing for no boxes at all', () => {
|
||||
expect(boundsOf([])).toBeNull();
|
||||
});
|
||||
|
||||
/** The scene view seeds the origin so a template drawn far to one side cannot hide it. */
|
||||
it('keeps a seed inside the result even when every box is far away', () => {
|
||||
const far: Box[] = [{ id: 'a', x: 500, y: 500, w: 10, h: 10 }];
|
||||
const origin = { minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
||||
expect(boundsOf(far, origin)).toEqual({ minX: 0, minY: 0, maxX: 510, maxY: 510 });
|
||||
});
|
||||
|
||||
it('still answers for no boxes when a seed is given', () => {
|
||||
const origin = { minX: 0, minY: 0, maxX: 0, maxY: 0 };
|
||||
expect(boundsOf([], origin)).toEqual(origin);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user