vexflow-native 2.0.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/module/renderer/Layout/DocumentLayout.js +47 -36
- package/lib/module/renderer/Layout/DocumentLayout.js.map +1 -1
- package/lib/module/renderer/Layout/LayoutMetrics.js +7 -1
- package/lib/module/renderer/Layout/LayoutMetrics.js.map +1 -1
- package/lib/module/renderer/Layout/VerticalSpacing.js +31 -2
- package/lib/module/renderer/Layout/VerticalSpacing.js.map +1 -1
- package/lib/module/renderer/constants.js +5 -1
- package/lib/module/renderer/constants.js.map +1 -1
- package/lib/module/renderer/engraveScore.js +202 -0
- package/lib/module/renderer/engraveScore.js.map +1 -0
- package/lib/module/renderer/index.js +1 -0
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/module/renderer/layout.js +4 -1
- package/lib/module/renderer/layout.js.map +1 -1
- package/lib/module/renderer/measure.js +12 -3
- package/lib/module/renderer/measure.js.map +1 -1
- package/lib/module/renderer/measureModifiers.js +5 -4
- package/lib/module/renderer/measureModifiers.js.map +1 -1
- package/lib/module/renderer/render.js +2 -1
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/systemExtents.js +104 -0
- package/lib/module/renderer/systemExtents.js.map +1 -0
- package/lib/module/renderer/useScoreRecording.js +19 -109
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/typescript/src/renderer/Layout/DocumentLayout.d.ts.map +1 -1
- package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts +2 -2
- package/lib/typescript/src/renderer/Layout/LayoutMetrics.d.ts.map +1 -1
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts +7 -0
- package/lib/typescript/src/renderer/Layout/VerticalSpacing.d.ts.map +1 -1
- package/lib/typescript/src/renderer/constants.d.ts.map +1 -1
- package/lib/typescript/src/renderer/engraveScore.d.ts +101 -0
- package/lib/typescript/src/renderer/engraveScore.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +1 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/layout.d.ts +1 -0
- package/lib/typescript/src/renderer/layout.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measure.d.ts +5 -0
- package/lib/typescript/src/renderer/measure.d.ts.map +1 -1
- package/lib/typescript/src/renderer/measureModifiers.d.ts +4 -3
- package/lib/typescript/src/renderer/measureModifiers.d.ts.map +1 -1
- package/lib/typescript/src/renderer/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/systemExtents.d.ts +15 -0
- package/lib/typescript/src/renderer/systemExtents.d.ts.map +1 -0
- package/lib/typescript/src/renderer/types.d.ts +32 -0
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +3 -20
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/renderer/Layout/DocumentLayout.ts +94 -44
- package/src/renderer/Layout/LayoutMetrics.ts +9 -2
- package/src/renderer/Layout/VerticalSpacing.ts +77 -2
- package/src/renderer/constants.ts +4 -0
- package/src/renderer/engraveScore.ts +338 -0
- package/src/renderer/index.ts +6 -0
- package/src/renderer/layout.ts +5 -2
- package/src/renderer/measure.tsx +27 -3
- package/src/renderer/measureModifiers.ts +7 -4
- package/src/renderer/render.tsx +7 -1
- package/src/renderer/systemExtents.ts +134 -0
- package/src/renderer/types.ts +32 -0
- package/src/renderer/useScoreRecording.ts +27 -176
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { SkTypefaceFontProvider } from 'react-native-skia';
|
|
2
|
+
import type { VexflowRecordingCommand } from '../base';
|
|
3
|
+
import { type VexflowRecordingGroupIndex } from '../base/VexflowRecordingIndex';
|
|
4
|
+
import type { Score } from '../state';
|
|
5
|
+
import { type ResolvedScoreColorScheme, type ScoreColorScheme } from './colorScheme';
|
|
6
|
+
import { type ScoreLayoutPlan } from './layout';
|
|
7
|
+
import { type MeasuredScore } from './measure';
|
|
8
|
+
import type { RendererRect, RendererSize, RendererType, ScoreItemHooks, ScoreItemsLayout, ScoreOptions, ScoreRendererOptions } from './types';
|
|
9
|
+
export interface EngraveScoreParams extends ScoreItemHooks {
|
|
10
|
+
score: Score;
|
|
11
|
+
defaultFont: string;
|
|
12
|
+
fontManager: SkTypefaceFontProvider;
|
|
13
|
+
colorScheme?: ScoreColorScheme;
|
|
14
|
+
options?: ScoreRendererOptions;
|
|
15
|
+
/** Default `document`. */
|
|
16
|
+
rendererType?: RendererType;
|
|
17
|
+
/** View-space width the score is laid out against. */
|
|
18
|
+
width: number;
|
|
19
|
+
/**
|
|
20
|
+
* View-space height. Only `infiniteScore`, which centers on it, and a
|
|
21
|
+
* score without measures read it. Default 0.
|
|
22
|
+
*/
|
|
23
|
+
height?: number;
|
|
24
|
+
}
|
|
25
|
+
/** One system of an engraving, in content space. */
|
|
26
|
+
export interface ScoreSystemLayout {
|
|
27
|
+
groupId: string;
|
|
28
|
+
/** Index within the staff group. */
|
|
29
|
+
systemIndex: number;
|
|
30
|
+
x: number;
|
|
31
|
+
width: number;
|
|
32
|
+
/**
|
|
33
|
+
* `y`/`height` cover the system's layout band and everything drawn for it
|
|
34
|
+
* (clefs, ledger lines, stems, modifiers, text), so clipping the commands
|
|
35
|
+
* to this band cuts nothing off.
|
|
36
|
+
*/
|
|
37
|
+
y: number;
|
|
38
|
+
height: number;
|
|
39
|
+
measureIndices: number[];
|
|
40
|
+
}
|
|
41
|
+
export interface ScoreEngraving {
|
|
42
|
+
/**
|
|
43
|
+
* Display list in content space (VexFlow units before `render.scale`);
|
|
44
|
+
* replay it with `renderVexflowRecordingCommands`.
|
|
45
|
+
*/
|
|
46
|
+
commands: readonly VexflowRecordingCommand[];
|
|
47
|
+
/** Content space; multiply by `render.scale` for view space. */
|
|
48
|
+
contentSize: RendererSize;
|
|
49
|
+
/** Top to bottom per staff group. */
|
|
50
|
+
systems: ScoreSystemLayout[];
|
|
51
|
+
/** View space, the value `ScoreRenderer` passes to `onItemsLayout`. */
|
|
52
|
+
itemsLayout: ScoreItemsLayout;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Engraves a score to a display list without mounting a view, for print,
|
|
56
|
+
* export or custom drawing. Same pipeline and output as `ScoreRenderer`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function engraveScore({ score, defaultFont, fontManager, colorScheme, options: userOptions, rendererType, width, height, decorateItem, onDrawItem, }: EngraveScoreParams): ScoreEngraving;
|
|
59
|
+
export interface ScoreMeasurement {
|
|
60
|
+
measuredScore: MeasuredScore;
|
|
61
|
+
measureMs: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ScoreRecording {
|
|
64
|
+
/** Recorded draw commands, content-space coordinates. */
|
|
65
|
+
commands: readonly VexflowRecordingCommand[];
|
|
66
|
+
/**
|
|
67
|
+
* `commands` bucketed by `groupId` so a style-override replay can redraw
|
|
68
|
+
* just the overridden items instead of the whole recording.
|
|
69
|
+
*/
|
|
70
|
+
groupIndex: VexflowRecordingGroupIndex;
|
|
71
|
+
/**
|
|
72
|
+
* Layout plan in content space; multiply its `contentSize` by the render
|
|
73
|
+
* scale for the view-space size that drives scrolling.
|
|
74
|
+
*/
|
|
75
|
+
layoutPlan: ScoreLayoutPlan;
|
|
76
|
+
/** Emitted geometry, already converted to view space. */
|
|
77
|
+
itemsLayout: ScoreItemsLayout;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The measuring pass. It does not depend on the viewport and is the most
|
|
81
|
+
* expensive pass, so callers that re-layout cache it apart from
|
|
82
|
+
* {@link recordScore}.
|
|
83
|
+
*/
|
|
84
|
+
export declare function measureScoreRecording({ score, options, fontManager, defaultFont, decorateItem, }: Pick<ScoreItemHooks, 'decorateItem'> & {
|
|
85
|
+
score: Score;
|
|
86
|
+
options: ScoreOptions;
|
|
87
|
+
fontManager: SkTypefaceFontProvider;
|
|
88
|
+
defaultFont: string;
|
|
89
|
+
}): ScoreMeasurement;
|
|
90
|
+
/** Layout and render passes; `viewport` is view space. */
|
|
91
|
+
export declare function recordScore({ measurement, score, options, rendererType, viewport, fontManager, defaultFont, colorScheme, decorateItem, onDrawItem, }: ScoreItemHooks & {
|
|
92
|
+
measurement: ScoreMeasurement;
|
|
93
|
+
score: Score;
|
|
94
|
+
options: ScoreOptions;
|
|
95
|
+
rendererType: RendererType;
|
|
96
|
+
viewport: RendererRect;
|
|
97
|
+
fontManager: SkTypefaceFontProvider;
|
|
98
|
+
defaultFont: string;
|
|
99
|
+
colorScheme: ResolvedScoreColorScheme;
|
|
100
|
+
}): ScoreRecording;
|
|
101
|
+
//# sourceMappingURL=engraveScore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engraveScore.d.ts","sourceRoot":"","sources":["../../../../src/renderer/engraveScore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAS7D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,sBA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AAe,CAAC;IAC5B,yDAAyD;IACzD,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,OAAO,EACP,WAAW,EACX,WAAW,EACX,YAAY,GACb,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG;IACxC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,gBAAgB,CASnB;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,KAAK,EACL,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,GACX,EAAE,cAAc,GAAG;IAClB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,wBAAwB,CAAC;CACvC,GAAG,cAAc,CAyDjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as ScoreRenderer } from './ScoreRenderer';
|
|
2
|
+
export { engraveScore, type EngraveScoreParams, type ScoreEngraving, type ScoreSystemLayout, } from './engraveScore';
|
|
2
3
|
export * from './colorScheme';
|
|
3
4
|
export * from './types';
|
|
4
5
|
export { Annotation, Articulation, Modifier, Ornament, StaveNote, } from 'vexflow';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/renderer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/renderer/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAYzD,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB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,EAC1B,QAAQ,EAAE,YAAY,GACrB,eAAe,CAwDjB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,GAC3B,OAAO,CAIT"}
|
|
@@ -8,6 +8,11 @@ export interface MeasuredMeasure {
|
|
|
8
8
|
staffIds: string[];
|
|
9
9
|
staffBounds: StaffVerticalBounds[];
|
|
10
10
|
intrinsicNoteWidth: number;
|
|
11
|
+
/**
|
|
12
|
+
* Extra width the measure needs when it starts a system and
|
|
13
|
+
* `spacing.clefOnEachSystem` adds its clef; absent = 0.
|
|
14
|
+
*/
|
|
15
|
+
systemStartClefWidth?: number;
|
|
11
16
|
}
|
|
12
17
|
export interface MeasuredScore {
|
|
13
18
|
measures: MeasuredMeasure[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../../../src/renderer/measure.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,UAAU,CAAC;AAc7C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQ3D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"measure.d.ts","sourceRoot":"","sources":["../../../../src/renderer/measure.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,UAAU,CAAC;AAc7C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAQ3D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAYD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,EAAE,YAAY,EAAE,GAAE,IAAI,CAAC,cAAc,EAAE,cAAc,CAAM,GAC1D,aAAa,CAqIf"}
|
|
@@ -10,10 +10,11 @@ export interface ResolvedMeasureModifiers {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Resolves the tri-state measure modifiers: `true` shows, `false` hides,
|
|
13
|
-
* `undefined` falls back to the default (clef on the first measure
|
|
14
|
-
* meter and key signature hidden,
|
|
13
|
+
* `undefined` falls back to the default (clef on the first measure, and on
|
|
14
|
+
* a measure that `startsSystemWithClef`; meter and key signature hidden,
|
|
15
|
+
* single barlines).
|
|
15
16
|
*/
|
|
16
|
-
export declare function resolveMeasureModifiers(measure: Pick<Measure, 'leftModifiers' | 'rightModifiers'>, measureIndex: number): ResolvedMeasureModifiers;
|
|
17
|
+
export declare function resolveMeasureModifiers(measure: Pick<Measure, 'leftModifiers' | 'rightModifiers'>, measureIndex: number, startsSystemWithClef?: boolean): ResolvedMeasureModifiers;
|
|
17
18
|
export declare function applyMeasureModifiers(stave: Stave, modifiers: ResolvedMeasureModifiers, resolvedState: ResolvedMeasureState): Stave;
|
|
18
19
|
/** Major-key VexFlow spec for the key's accidentals, respelt enharmonically beyond 7 sharps/flats. */
|
|
19
20
|
export declare function keySignatureToVFSpec(keySignature: KeySignature): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureModifiers.d.ts","sourceRoot":"","sources":["../../../../src/renderer/measureModifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAyB,MAAM,SAAS,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAW,YAAY,EAAE,OAAO,EAAQ,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;CACrB;AAwDD
|
|
1
|
+
{"version":3,"file":"measureModifiers.d.ts","sourceRoot":"","sources":["../../../../src/renderer/measureModifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAyB,MAAM,SAAS,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAW,YAAY,EAAE,OAAO,EAAQ,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;CACrB;AAwDD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB,CAAC,EAC1D,YAAY,EAAE,MAAM,EACpB,oBAAoB,UAAQ,GAC3B,wBAAwB,CAW1B;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,wBAAwB,EACnC,aAAa,EAAE,oBAAoB,GAClC,KAAK,CA+BP;AAED,sGAAsG;AACtG,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAOvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/renderer/render.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAEV,KAAK,EAGN,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAUlB,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG9E;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,uBAAuB,EAC5B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,YAAY,EACrB,KAAK,GAAE,cAAmB,GACzB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/renderer/render.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAEV,KAAK,EAGN,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAUlB,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG9E;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,uBAAuB,EAC5B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,YAAY,EACrB,KAAK,GAAE,cAAmB,GACzB,gBAAgB,CA6ClB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VexflowRecordingCommand } from '../base';
|
|
2
|
+
import type FontManager from '../base/FontManager';
|
|
3
|
+
interface VerticalBand {
|
|
4
|
+
y: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Grows each band to cover everything the recording draws for it. A command
|
|
9
|
+
* belongs to the band its vertical centre is in, or else the nearest one.
|
|
10
|
+
* Curve control points count as drawn, so a band can come out slightly taller
|
|
11
|
+
* than its ink, never shorter.
|
|
12
|
+
*/
|
|
13
|
+
export declare function coverDrawnExtents<Band extends VerticalBand>(bands: readonly Band[], commands: readonly VexflowRecordingCommand[], fontManager: FontManager): Band[];
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=systemExtents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemExtents.d.ts","sourceRoot":"","sources":["../../../../src/renderer/systemExtents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAQnD,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,YAAY,EACzD,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,WAAW,EAAE,WAAW,GACvB,IAAI,EAAE,CAqBR"}
|
|
@@ -122,6 +122,38 @@ export interface ScoreInsets {
|
|
|
122
122
|
export interface ScoreSpacing {
|
|
123
123
|
staffGap: number;
|
|
124
124
|
minIntrinsicSizeMultiplier: number;
|
|
125
|
+
/**
|
|
126
|
+
* `documentEven` only: place every system of a staff group at one uniform
|
|
127
|
+
* pitch. All systems share the tallest system's vertical extent, so staves
|
|
128
|
+
* sit on a fixed grid instead of each system advancing by its own height —
|
|
129
|
+
* rows of two renderers laid out side by side stay aligned. Default false.
|
|
130
|
+
*/
|
|
131
|
+
uniformSystemPitch: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* `document` only: indent of the first system of each staff group, in
|
|
134
|
+
* content units (before `render.scale`). That system starts later and is
|
|
135
|
+
* narrower by the same amount. Default 0.
|
|
136
|
+
*/
|
|
137
|
+
firstSystemIndent: number;
|
|
138
|
+
/**
|
|
139
|
+
* Vertical gap between systems in content units, clamped to >= 0. With
|
|
140
|
+
* `uniformSystemPitch` the pitch is the shared system height plus this gap.
|
|
141
|
+
* Undefined or non-finite = the built-in `max(82, staffGap / 8)`.
|
|
142
|
+
*/
|
|
143
|
+
systemGap?: number;
|
|
144
|
+
/**
|
|
145
|
+
* `document` only: `justify` stretches the last system of each staff group
|
|
146
|
+
* to the full width like every other system; `natural` keeps its intrinsic
|
|
147
|
+
* width (a one-system score counts as its own last system). `documentEven`
|
|
148
|
+
* never stretches a partial last system. Default `justify`.
|
|
149
|
+
*/
|
|
150
|
+
lastSystemFill: 'justify' | 'natural';
|
|
151
|
+
/**
|
|
152
|
+
* Draw the clef on the first measure of every system instead of the first
|
|
153
|
+
* measure of the score only; line breaking reserves its width. A measure
|
|
154
|
+
* with `leftModifiers.showClef: false` still hides it. Default false.
|
|
155
|
+
*/
|
|
156
|
+
clefOnEachSystem: boolean;
|
|
125
157
|
}
|
|
126
158
|
export interface RenderOptions {
|
|
127
159
|
/** Currently unused — reserved for future raster-density control. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/renderer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,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E,CAAC,EAAE,MAAM,CAAC;IACV,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC,WAAW,EAAE,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa,EAAE,YAAY;CAAG;AAEpE,MAAM,WAAW,eAAgB,SAAQ,YAAY;CAAG"}
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import type { SkTypefaceFontProvider } from 'react-native-skia';
|
|
2
|
-
import type { VexflowRecordingCommand } from '../base';
|
|
3
|
-
import { type VexflowRecordingGroupIndex } from '../base/VexflowRecordingIndex';
|
|
4
2
|
import type { Score } from '../state';
|
|
5
|
-
import { type ScoreLayoutPlan } from './layout';
|
|
6
3
|
import type { ResolvedScoreColorScheme } from './colorScheme';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
commands: readonly VexflowRecordingCommand[];
|
|
11
|
-
/**
|
|
12
|
-
* `commands` bucketed by `groupId` so a style-override replay can redraw
|
|
13
|
-
* just the overridden items instead of the whole recording.
|
|
14
|
-
*/
|
|
15
|
-
groupIndex: VexflowRecordingGroupIndex;
|
|
16
|
-
/**
|
|
17
|
-
* Layout plan in content space; multiply its `contentSize` by the render
|
|
18
|
-
* scale for the view-space size that drives scrolling.
|
|
19
|
-
*/
|
|
20
|
-
layoutPlan: ScoreLayoutPlan;
|
|
21
|
-
/** Emitted geometry, already converted to view space. */
|
|
22
|
-
itemsLayout: ScoreItemsLayout;
|
|
23
|
-
}
|
|
4
|
+
import { type ScoreRecording } from './engraveScore';
|
|
5
|
+
import type { RendererRect, RendererType, ScoreItemHooks, ScoreOptions } from './types';
|
|
6
|
+
/** Memoised `engraveScore` pipeline for a mounted renderer. */
|
|
24
7
|
export declare function useScoreRecording({ decorateItem, defaultFont, enabled, fontManager, colorScheme, onDrawItem, options, rendererType, score, viewport, }: ScoreItemHooks & {
|
|
25
8
|
defaultFont: string;
|
|
26
9
|
enabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useScoreRecording.d.ts","sourceRoot":"","sources":["../../../../src/renderer/useScoreRecording.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EAEd,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,EAChC,YAAY,EACZ,WAAW,EACX,OAAc,EACd,WAAW,EACX,WAAW,EACX,UAAU,EACV,OAAO,EACP,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE,cAAc,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;CACxB,GAAG,cAAc,CAmEjB"}
|
package/package.json
CHANGED
|
@@ -8,11 +8,16 @@ import type {
|
|
|
8
8
|
SystemLayoutPlan,
|
|
9
9
|
} from '../layout';
|
|
10
10
|
import { getSystemGap } from './LayoutMetrics';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
resolveSystemVerticalLayout,
|
|
13
|
+
resolveUniformSystemVerticalLayout,
|
|
14
|
+
} from './VerticalSpacing';
|
|
12
15
|
|
|
13
16
|
type DocumentLine = {
|
|
14
17
|
measures: MeasuredGroupMeasure[];
|
|
15
18
|
intrinsicWidth: number;
|
|
19
|
+
availableWidth: number;
|
|
20
|
+
indent: number;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
export function resolveDocumentEvenMeasureWidth(
|
|
@@ -31,11 +36,24 @@ export function resolveDocumentEvenMeasureWidth(
|
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
let measuresPerFullLine = Math.max(
|
|
35
40
|
1,
|
|
36
41
|
Math.floor(availableWidth / widestMeasure)
|
|
37
42
|
);
|
|
38
43
|
|
|
44
|
+
// A clef added at a system start has to fit the equal measure width too.
|
|
45
|
+
while (
|
|
46
|
+
measuresPerFullLine > 1 &&
|
|
47
|
+
measuredScore.measures.some(
|
|
48
|
+
(measure) =>
|
|
49
|
+
measure.measureIndex % measuresPerFullLine === 0 &&
|
|
50
|
+
measure.intrinsicNoteWidth + (measure.systemStartClefWidth ?? 0) >
|
|
51
|
+
availableWidth / measuresPerFullLine
|
|
52
|
+
)
|
|
53
|
+
) {
|
|
54
|
+
measuresPerFullLine -= 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
return {
|
|
40
58
|
measuresPerFullLine,
|
|
41
59
|
equalMeasureWidth: availableWidth / measuresPerFullLine,
|
|
@@ -63,22 +81,37 @@ export function layoutDocumentEvenGroup(
|
|
|
63
81
|
}
|
|
64
82
|
|
|
65
83
|
let cursorY = origin.y;
|
|
66
|
-
const systemGap = getSystemGap(options.spacing
|
|
84
|
+
const systemGap = getSystemGap(options.spacing);
|
|
85
|
+
const chunks: MeasuredGroupMeasure[][] = [];
|
|
67
86
|
|
|
68
87
|
for (
|
|
69
|
-
let
|
|
88
|
+
let startIndex = 0;
|
|
70
89
|
startIndex < group.measures.length;
|
|
71
|
-
|
|
90
|
+
startIndex += measuresPerFullLine
|
|
72
91
|
) {
|
|
73
|
-
|
|
74
|
-
startIndex,
|
|
75
|
-
startIndex + measuresPerFullLine
|
|
76
|
-
);
|
|
77
|
-
const verticalLayout = resolveSystemVerticalLayout(
|
|
78
|
-
chunk,
|
|
79
|
-
group.staves.length,
|
|
80
|
-
options.spacing.staffGap
|
|
92
|
+
chunks.push(
|
|
93
|
+
group.measures.slice(startIndex, startIndex + measuresPerFullLine)
|
|
81
94
|
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// One shared layout puts every staff on a fixed grid: system N's first
|
|
98
|
+
// staff sits exactly N pitches below system 0's.
|
|
99
|
+
const uniformVerticalLayout = options.spacing.uniformSystemPitch
|
|
100
|
+
? resolveUniformSystemVerticalLayout(
|
|
101
|
+
chunks,
|
|
102
|
+
group.staves.length,
|
|
103
|
+
options.spacing.staffGap
|
|
104
|
+
)
|
|
105
|
+
: undefined;
|
|
106
|
+
|
|
107
|
+
for (const [systemIndex, chunk] of chunks.entries()) {
|
|
108
|
+
const verticalLayout =
|
|
109
|
+
uniformVerticalLayout ??
|
|
110
|
+
resolveSystemVerticalLayout(
|
|
111
|
+
chunk,
|
|
112
|
+
group.staves.length,
|
|
113
|
+
options.spacing.staffGap
|
|
114
|
+
);
|
|
82
115
|
let cursorX = origin.x;
|
|
83
116
|
|
|
84
117
|
systems.push({
|
|
@@ -140,24 +173,35 @@ export function layoutDocumentGroup(
|
|
|
140
173
|
};
|
|
141
174
|
}
|
|
142
175
|
|
|
143
|
-
const
|
|
176
|
+
const { firstSystemIndent, lastSystemFill } = options.spacing;
|
|
177
|
+
const lines = splitDocumentLines(
|
|
178
|
+
group.measures,
|
|
179
|
+
availableWidth,
|
|
180
|
+
firstSystemIndent
|
|
181
|
+
);
|
|
144
182
|
let cursorY = origin.y;
|
|
145
|
-
const systemGap = getSystemGap(options.spacing
|
|
183
|
+
const systemGap = getSystemGap(options.spacing);
|
|
146
184
|
|
|
147
185
|
for (const [systemIndex, line] of lines.entries()) {
|
|
148
|
-
const
|
|
186
|
+
const fullWidth =
|
|
187
|
+
line.availableWidth > 0 ? line.availableWidth : line.intrinsicWidth;
|
|
188
|
+
const lineWidth =
|
|
189
|
+
lastSystemFill === 'natural' && systemIndex === lines.length - 1
|
|
190
|
+
? Math.min(fullWidth, line.intrinsicWidth)
|
|
191
|
+
: fullWidth;
|
|
149
192
|
const stretchRatio = lineWidth / line.intrinsicWidth;
|
|
150
193
|
const verticalLayout = resolveSystemVerticalLayout(
|
|
151
194
|
line.measures,
|
|
152
195
|
group.staves.length,
|
|
153
196
|
options.spacing.staffGap
|
|
154
197
|
);
|
|
155
|
-
|
|
198
|
+
const systemX = origin.x + line.indent;
|
|
199
|
+
let cursorX = systemX;
|
|
156
200
|
|
|
157
201
|
systems.push({
|
|
158
202
|
groupId: group.groupId,
|
|
159
203
|
systemIndex,
|
|
160
|
-
x:
|
|
204
|
+
x: systemX,
|
|
161
205
|
y: cursorY,
|
|
162
206
|
width: lineWidth,
|
|
163
207
|
height: verticalLayout.height,
|
|
@@ -166,8 +210,11 @@ export function layoutDocumentGroup(
|
|
|
166
210
|
measureIndices: line.measures.map((measure) => measure.measureIndex),
|
|
167
211
|
});
|
|
168
212
|
|
|
169
|
-
for (const measure of line.measures) {
|
|
170
|
-
const width =
|
|
213
|
+
for (const [lineIndex, measure] of line.measures.entries()) {
|
|
214
|
+
const width =
|
|
215
|
+
(lineIndex === 0
|
|
216
|
+
? getSystemStartWidth(measure)
|
|
217
|
+
: getMeasureLineWidth(measure)) * stretchRatio;
|
|
171
218
|
|
|
172
219
|
measures.push({
|
|
173
220
|
groupId: group.groupId,
|
|
@@ -196,40 +243,39 @@ export function layoutDocumentGroup(
|
|
|
196
243
|
|
|
197
244
|
function splitDocumentLines(
|
|
198
245
|
measures: MeasuredGroupMeasure[],
|
|
199
|
-
availableWidth: number
|
|
246
|
+
availableWidth: number,
|
|
247
|
+
firstSystemIndent: number
|
|
200
248
|
): DocumentLine[] {
|
|
201
249
|
const lines: DocumentLine[] = [];
|
|
202
|
-
let
|
|
203
|
-
let lineWidth = 0;
|
|
250
|
+
let line: DocumentLine | undefined;
|
|
204
251
|
|
|
205
252
|
for (const measure of measures) {
|
|
206
253
|
const measureWidth = getMeasureLineWidth(measure);
|
|
207
254
|
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
|
|
255
|
+
if (
|
|
256
|
+
line &&
|
|
257
|
+
!(
|
|
258
|
+
line.availableWidth > 0 &&
|
|
259
|
+
line.intrinsicWidth + measureWidth > line.availableWidth
|
|
260
|
+
)
|
|
261
|
+
) {
|
|
262
|
+
line.measures.push(measure);
|
|
263
|
+
line.intrinsicWidth += measureWidth;
|
|
211
264
|
continue;
|
|
212
265
|
}
|
|
213
266
|
|
|
214
|
-
|
|
215
|
-
lines.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
lineMeasures = [measure];
|
|
220
|
-
lineWidth = measureWidth;
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
267
|
+
const indent =
|
|
268
|
+
lines.length === 0 && firstSystemIndent < availableWidth
|
|
269
|
+
? firstSystemIndent
|
|
270
|
+
: 0;
|
|
223
271
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
intrinsicWidth: lineWidth,
|
|
232
|
-
});
|
|
272
|
+
line = {
|
|
273
|
+
measures: [measure],
|
|
274
|
+
intrinsicWidth: getSystemStartWidth(measure),
|
|
275
|
+
availableWidth: availableWidth - indent,
|
|
276
|
+
indent,
|
|
277
|
+
};
|
|
278
|
+
lines.push(line);
|
|
233
279
|
}
|
|
234
280
|
|
|
235
281
|
return lines;
|
|
@@ -238,3 +284,7 @@ function splitDocumentLines(
|
|
|
238
284
|
function getMeasureLineWidth(measure: MeasuredGroupMeasure): number {
|
|
239
285
|
return Math.max(measure.intrinsicWidth, 1);
|
|
240
286
|
}
|
|
287
|
+
|
|
288
|
+
function getSystemStartWidth(measure: MeasuredGroupMeasure): number {
|
|
289
|
+
return getMeasureLineWidth(measure) + (measure.systemStartClefWidth ?? 0);
|
|
290
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RendererRect, ScoreOptions } from '../types';
|
|
1
|
+
import type { RendererRect, ScoreOptions, ScoreSpacing } from '../types';
|
|
2
2
|
|
|
3
3
|
const MIN_SYSTEM_GAP = 82;
|
|
4
4
|
const SYSTEM_GAP_DIVISOR = 8;
|
|
@@ -16,6 +16,13 @@ export function getAvailableDocumentWidth(
|
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function getSystemGap(
|
|
19
|
+
export function getSystemGap({
|
|
20
|
+
staffGap,
|
|
21
|
+
systemGap,
|
|
22
|
+
}: Pick<ScoreSpacing, 'staffGap' | 'systemGap'>): number {
|
|
23
|
+
if (systemGap !== undefined && Number.isFinite(systemGap)) {
|
|
24
|
+
return Math.max(0, systemGap);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
return Math.max(MIN_SYSTEM_GAP, staffGap / SYSTEM_GAP_DIVISOR);
|
|
21
28
|
}
|
|
@@ -21,8 +21,58 @@ export function resolveSystemVerticalLayout(
|
|
|
21
21
|
): SystemVerticalLayout {
|
|
22
22
|
const staffBounds = resolveStaffBounds(measures, staffCount);
|
|
23
23
|
const rawStaffYOffsets = resolveRawStaffYOffsets(staffBounds, staffGap);
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
return shiftBelowOrigin(
|
|
26
|
+
rawStaffYOffsets,
|
|
27
|
+
getVisibleTop(staffBounds, rawStaffYOffsets),
|
|
28
|
+
getVisibleBottom(staffBounds, rawStaffYOffsets)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves one vertical layout shared by every system in `systems`. Each
|
|
34
|
+
* inter-staff distance is the largest any system needs and the top shift
|
|
35
|
+
* clears the tallest above-staff content of any system, so staves sit at the
|
|
36
|
+
* same offsets in every system and all systems share one height.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveUniformSystemVerticalLayout(
|
|
39
|
+
systems: MeasuredGroupMeasure[][],
|
|
40
|
+
staffCount: number,
|
|
41
|
+
staffGap: number
|
|
42
|
+
): SystemVerticalLayout {
|
|
43
|
+
if (systems.length === 0) {
|
|
44
|
+
return resolveSystemVerticalLayout([], staffCount, staffGap);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const staffBoundsBySystem = systems.map((measures) =>
|
|
48
|
+
resolveStaffBounds(measures, staffCount)
|
|
49
|
+
);
|
|
50
|
+
const rawStaffYOffsets = resolveWidestStaffYOffsets(
|
|
51
|
+
staffBoundsBySystem.map((staffBounds) =>
|
|
52
|
+
resolveRawStaffYOffsets(staffBounds, staffGap)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return shiftBelowOrigin(
|
|
57
|
+
rawStaffYOffsets,
|
|
58
|
+
Math.min(
|
|
59
|
+
...staffBoundsBySystem.map((staffBounds) =>
|
|
60
|
+
getVisibleTop(staffBounds, rawStaffYOffsets)
|
|
61
|
+
)
|
|
62
|
+
),
|
|
63
|
+
Math.max(
|
|
64
|
+
...staffBoundsBySystem.map((staffBounds) =>
|
|
65
|
+
getVisibleBottom(staffBounds, rawStaffYOffsets)
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function shiftBelowOrigin(
|
|
72
|
+
rawStaffYOffsets: number[],
|
|
73
|
+
rawVisibleTop: number,
|
|
74
|
+
rawVisibleBottom: number
|
|
75
|
+
): SystemVerticalLayout {
|
|
26
76
|
const topShift = rawVisibleTop < 0 ? -rawVisibleTop : 0;
|
|
27
77
|
const staffYOffsets = rawStaffYOffsets.map((offset) => offset + topShift);
|
|
28
78
|
const visibleTop = rawVisibleTop + topShift;
|
|
@@ -84,6 +134,31 @@ function resolveRawStaffYOffsets(
|
|
|
84
134
|
return offsets;
|
|
85
135
|
}
|
|
86
136
|
|
|
137
|
+
function resolveWidestStaffYOffsets(
|
|
138
|
+
staffYOffsetsBySystem: number[][]
|
|
139
|
+
): number[] {
|
|
140
|
+
const staffCount = staffYOffsetsBySystem[0]?.length ?? 0;
|
|
141
|
+
const offsets: number[] = [];
|
|
142
|
+
|
|
143
|
+
for (let staffIndex = 0; staffIndex < staffCount; staffIndex++) {
|
|
144
|
+
if (staffIndex === 0) {
|
|
145
|
+
offsets.push(0);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const widestDistance = Math.max(
|
|
150
|
+
...staffYOffsetsBySystem.map(
|
|
151
|
+
(staffYOffsets) =>
|
|
152
|
+
staffYOffsets[staffIndex]! - staffYOffsets[staffIndex - 1]!
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
offsets.push(offsets[staffIndex - 1]! + widestDistance);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return offsets;
|
|
160
|
+
}
|
|
161
|
+
|
|
87
162
|
function getVisibleTop(
|
|
88
163
|
staffBounds: StaffVerticalBounds[],
|
|
89
164
|
staffYOffsets: number[]
|