feat(domain): per-view minimum point radius in preview state
PreviewState.min_point_radius maps a view id to the smallest point hitbox radius that passes TooSmall on the smallest preview, so the sheet editor can mark it on a size slider. Twin constants named in layer.rs; frame.rs shares one first-view drawing lookup.
This commit is contained in:
1 parent
56c75b12ef
commit
5ca2b7e3ad
8 files changed
+202
-9
No files matched your search
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* The core states, per view, the smallest radius a point may have (the sheet editor's size
|
||||
* slider marks it): the bundled draft's main view, from its frame and the preview size.
|
||||
*/
|
||||
import { beforeAll, describe, expect, it } from 'vitest'
|
||||
import { CataloguePreview } from '@/catalogue/preview'
|
||||
import { coreRuntime, setCoreRuntime } from '@/core/runtime'
|
||||
import { bundledSheet } from '../helpers/sheet'
|
||||
import { testCoreRuntime } from '../helpers/core'
|
||||
|
||||
beforeAll(async () => {
|
||||
setCoreRuntime(await testCoreRuntime())
|
||||
})
|
||||
|
||||
describe('min_point_radius of the preview state', () => {
|
||||
it('gives the bundled draft its main-view radius, none for an unknown view', async () => {
|
||||
const bundle = await bundledSheet()
|
||||
const [assetId] = Object.keys(bundle.assets)
|
||||
const preview = new CataloguePreview(
|
||||
coreRuntime(),
|
||||
{ status: 'draft', document: JSON.stringify(bundle.document) },
|
||||
[
|
||||
{
|
||||
assetId,
|
||||
sha256: bundle.assetHashes[assetId],
|
||||
bytes: new TextEncoder().encode(bundle.assets[assetId]),
|
||||
},
|
||||
],
|
||||
)
|
||||
const state = preview.state()
|
||||
if (!state.ok) throw new Error(state.kind)
|
||||
const radii = state.value.min_point_radius
|
||||
expect(radii['main']).toBeCloseTo(26.5, 1)
|
||||
expect(radii['nowhere'] ?? null).toBeNull()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user