|
@@ -108,7 +108,7 @@ export abstract class MusicSheetCalculator {
|
|
|
|
|
|
public initialize(graphicalMusicSheet: GraphicalMusicSheet): void {
|
|
|
this.graphicalMusicSheet = graphicalMusicSheet;
|
|
|
- this.rules = graphicalMusicSheet.ParentMusicSheet.rules;
|
|
|
+ this.rules = graphicalMusicSheet.ParentMusicSheet.Rules;
|
|
|
this.prepareGraphicalMusicSheet();
|
|
|
//this.calculate();
|
|
|
}
|
|
@@ -350,7 +350,7 @@ export abstract class MusicSheetCalculator {
|
|
|
private calculateSingleMeasureNumberPlacement(measure: GraphicalMeasure, staffLine: StaffLine, musicSystem: MusicSystem): void {
|
|
|
const labelNumber: string = measure.MeasureNumber.toString();
|
|
|
const graphicalLabel: GraphicalLabel = new GraphicalLabel(new Label(labelNumber), this.rules.MeasureNumberLabelHeight,
|
|
|
- TextAlignmentEnum.LeftBottom);
|
|
|
+ TextAlignmentEnum.LeftBottom, this.rules);
|
|
|
|
|
|
const skyBottomLineCalculator: SkyBottomLineCalculator = staffLine.SkyBottomLineCalculator;
|
|
|
|
|
@@ -581,15 +581,15 @@ export abstract class MusicSheetCalculator {
|
|
|
if (allMeasures === undefined) {
|
|
|
return;
|
|
|
}
|
|
|
- if (EngravingRules.Rules.MinMeasureToDrawIndex > allMeasures.length - 1) {
|
|
|
+ if (this.rules.MinMeasureToDrawIndex > allMeasures.length - 1) {
|
|
|
log.debug("minimum measure to draw index out of range. resetting min measure index to limit.");
|
|
|
- EngravingRules.Rules.MinMeasureToDrawIndex = allMeasures.length - 1;
|
|
|
+ this.rules.MinMeasureToDrawIndex = allMeasures.length - 1;
|
|
|
}
|
|
|
|
|
|
// visible 2D-MeasureList
|
|
|
const visibleMeasureList: GraphicalMeasure[][] = [];
|
|
|
- for (let idx: number = EngravingRules.Rules.MinMeasureToDrawIndex, len: number = allMeasures.length;
|
|
|
- idx < len && idx <= EngravingRules.Rules.MaxMeasureToDrawIndex; ++idx) {
|
|
|
+ for (let idx: number = this.rules.MinMeasureToDrawIndex, len: number = allMeasures.length;
|
|
|
+ idx < len && idx <= this.rules.MaxMeasureToDrawIndex; ++idx) {
|
|
|
const graphicalMeasures: GraphicalMeasure[] = allMeasures[idx];
|
|
|
const visiblegraphicalMeasures: GraphicalMeasure[] = [];
|
|
|
for (let idx2: number = 0, len2: number = graphicalMeasures.length; idx2 < len2; ++idx2) {
|
|
@@ -598,7 +598,7 @@ export abstract class MusicSheetCalculator {
|
|
|
if (graphicalMeasure.isVisible()) {
|
|
|
visiblegraphicalMeasures.push(graphicalMeasure);
|
|
|
|
|
|
- if (EngravingRules.Rules.ColoringEnabled) {
|
|
|
+ if (this.rules.ColoringEnabled) {
|
|
|
// (re-)color notes
|
|
|
for (const staffEntry of graphicalMeasure.staffEntries) {
|
|
|
for (const gve of staffEntry.graphicalVoiceEntries) {
|
|
@@ -641,7 +641,7 @@ export abstract class MusicSheetCalculator {
|
|
|
this.optimizeRestPlacement();
|
|
|
// possible Displacement of RestNotes
|
|
|
this.calculateStaffEntryArticulationMarks();
|
|
|
- if (EngravingRules.Rules.RenderSlurs) { // technically we should separate slurs and ties, but shouldn't be relevant for now
|
|
|
+ if (this.rules.RenderSlurs) { // technically we should separate slurs and ties, but shouldn't be relevant for now
|
|
|
// calculate Ties
|
|
|
this.calculateTieCurves();
|
|
|
}
|
|
@@ -653,14 +653,14 @@ export abstract class MusicSheetCalculator {
|
|
|
this.calculateTupletNumbers();
|
|
|
|
|
|
// calculate MeasureNumbers
|
|
|
- if (EngravingRules.Rules.RenderMeasureNumbers) {
|
|
|
+ if (this.rules.RenderMeasureNumbers) {
|
|
|
for (let idx: number = 0, len: number = this.musicSystems.length; idx < len; ++idx) {
|
|
|
const musicSystem: MusicSystem = this.musicSystems[idx];
|
|
|
this.calculateMeasureNumberPlacement(musicSystem);
|
|
|
}
|
|
|
}
|
|
|
// calculate Slurs
|
|
|
- if (!this.leadSheet && EngravingRules.Rules.RenderSlurs) {
|
|
|
+ if (!this.leadSheet && this.rules.RenderSlurs) {
|
|
|
this.calculateSlurs();
|
|
|
}
|
|
|
// calculate StaffEntry Ornaments
|
|
@@ -1237,7 +1237,7 @@ export abstract class MusicSheetCalculator {
|
|
|
label.fontHeight = fontHeight;
|
|
|
|
|
|
// TODO_RR: TextHeight from first Entry
|
|
|
- const graphLabel: GraphicalLabel = new GraphicalLabel(label, fontHeight, label.textAlignment, staffLine.PositionAndShape);
|
|
|
+ const graphLabel: GraphicalLabel = new GraphicalLabel(label, fontHeight, label.textAlignment, this.rules, staffLine.PositionAndShape);
|
|
|
graphLabel.Label.fontStyle = style;
|
|
|
const marginFactor: number = 1.1;
|
|
|
|
|
@@ -1291,7 +1291,7 @@ export abstract class MusicSheetCalculator {
|
|
|
|
|
|
if (multiTempoExpression.ContinuousTempo || multiTempoExpression.InstantaneousTempo) {
|
|
|
// TempoExpressions always on the first visible System's StaffLine // TODO is it though?
|
|
|
- if (EngravingRules.Rules.MinMeasureToDrawIndex > 0) {
|
|
|
+ if (this.rules.MinMeasureToDrawIndex > 0) {
|
|
|
return; // assuming that the tempo is always in measure 1 (idx 0), adding the expression causes issues when we don't draw measure 1
|
|
|
}
|
|
|
let staffLine: StaffLine = measures[0].ParentStaffLine;
|
|
@@ -1332,7 +1332,7 @@ export abstract class MusicSheetCalculator {
|
|
|
const lastInstruction: AbstractGraphicalInstruction = firstInstructionEntry.GraphicalInstructions.last();
|
|
|
relative.x = lastInstruction.PositionAndShape.RelativePosition.x;
|
|
|
}
|
|
|
- if (EngravingRules.Rules.CompactMode) {
|
|
|
+ if (this.rules.CompactMode) {
|
|
|
relative.x = staffLine.PositionAndShape.RelativePosition.x +
|
|
|
staffLine.Measures[0].PositionAndShape.RelativePosition.x;
|
|
|
}
|
|
@@ -1342,7 +1342,7 @@ export abstract class MusicSheetCalculator {
|
|
|
// const addAtLastList: GraphicalObject[] = [];
|
|
|
for (const entry of multiTempoExpression.EntriesList) {
|
|
|
let textAlignment: TextAlignmentEnum = TextAlignmentEnum.CenterBottom;
|
|
|
- if (EngravingRules.Rules.CompactMode) {
|
|
|
+ if (this.rules.CompactMode) {
|
|
|
textAlignment = TextAlignmentEnum.LeftBottom;
|
|
|
}
|
|
|
const graphLabel: GraphicalLabel = this.calculateLabel(staffLine,
|
|
@@ -1350,7 +1350,7 @@ export abstract class MusicSheetCalculator {
|
|
|
entry.label,
|
|
|
multiTempoExpression.getFontstyleOfFirstEntry(),
|
|
|
entry.Expression.Placement,
|
|
|
- EngravingRules.Rules.UnknownTextHeight,
|
|
|
+ this.rules.UnknownTextHeight,
|
|
|
textAlignment);
|
|
|
|
|
|
if (entry.Expression instanceof InstantaneousTempoExpression) {
|
|
@@ -1452,7 +1452,7 @@ export abstract class MusicSheetCalculator {
|
|
|
octaveShiftValue: OctaveEnum, linkedNotes: Note[] = undefined,
|
|
|
sourceStaffEntry: SourceStaffEntry = undefined): OctaveEnum {
|
|
|
if (voiceEntry.StemDirectionXml !== StemDirectionType.Undefined &&
|
|
|
- EngravingRules.Rules.SetWantedStemDirectionByXml &&
|
|
|
+ this.rules.SetWantedStemDirectionByXml &&
|
|
|
voiceEntry.StemDirectionXml !== undefined) {
|
|
|
voiceEntry.WantedStemDirection = voiceEntry.StemDirectionXml;
|
|
|
} else {
|
|
@@ -1556,16 +1556,16 @@ export abstract class MusicSheetCalculator {
|
|
|
for (const instrument of this.graphicalMusicSheet.ParentMusicSheet.Instruments) {
|
|
|
if (instrument.Voices.length > 0 && instrument.Voices[0].Visible) {
|
|
|
let renderedLabel: Label = instrument.NameLabel;
|
|
|
- if (!EngravingRules.Rules.RenderPartNames) {
|
|
|
+ if (!this.rules.RenderPartNames) {
|
|
|
renderedLabel = new Label("", renderedLabel.textAlignment, renderedLabel.font);
|
|
|
}
|
|
|
const graphicalLabel: GraphicalLabel = new GraphicalLabel(
|
|
|
- renderedLabel, this.rules.InstrumentLabelTextHeight, TextAlignmentEnum.LeftCenter);
|
|
|
+ renderedLabel, this.rules.InstrumentLabelTextHeight, TextAlignmentEnum.LeftCenter, this.rules);
|
|
|
graphicalLabel.setLabelPositionAndShapeBorders();
|
|
|
maxLabelLength = Math.max(maxLabelLength, graphicalLabel.PositionAndShape.MarginSize.width);
|
|
|
}
|
|
|
}
|
|
|
- if (!EngravingRules.Rules.RenderPartNames) {
|
|
|
+ if (!this.rules.RenderPartNames) {
|
|
|
return 0;
|
|
|
}
|
|
|
return maxLabelLength;
|
|
@@ -1573,37 +1573,40 @@ export abstract class MusicSheetCalculator {
|
|
|
|
|
|
protected calculateSheetLabelBoundingBoxes(): void {
|
|
|
const musicSheet: MusicSheet = this.graphicalMusicSheet.ParentMusicSheet;
|
|
|
- const defaultColorTitle: string = EngravingRules.Rules.DefaultColorTitle; // can be undefined => black
|
|
|
- if (musicSheet.Title !== undefined && EngravingRules.Rules.RenderTitle) {
|
|
|
- const title: GraphicalLabel = new GraphicalLabel(musicSheet.Title, this.rules.SheetTitleHeight, TextAlignmentEnum.CenterBottom);
|
|
|
+ const defaultColorTitle: string = this.rules.DefaultColorTitle; // can be undefined => black
|
|
|
+ if (musicSheet.Title !== undefined && this.rules.RenderTitle) {
|
|
|
+ const title: GraphicalLabel = new GraphicalLabel(musicSheet.Title, this.rules.SheetTitleHeight, TextAlignmentEnum.CenterBottom, this.rules);
|
|
|
title.Label.colorDefault = defaultColorTitle;
|
|
|
this.graphicalMusicSheet.Title = title;
|
|
|
title.setLabelPositionAndShapeBorders();
|
|
|
- } else if (!EngravingRules.Rules.RenderTitle) {
|
|
|
+ } else if (!this.rules.RenderTitle) {
|
|
|
this.graphicalMusicSheet.Title = undefined; // clear label if rendering it was disabled after last render
|
|
|
}
|
|
|
- if (musicSheet.Subtitle !== undefined && EngravingRules.Rules.RenderSubtitle) {
|
|
|
- const subtitle: GraphicalLabel = new GraphicalLabel(musicSheet.Subtitle, this.rules.SheetSubtitleHeight, TextAlignmentEnum.CenterCenter);
|
|
|
+ if (musicSheet.Subtitle !== undefined && this.rules.RenderSubtitle) {
|
|
|
+ const subtitle: GraphicalLabel = new GraphicalLabel(
|
|
|
+ musicSheet.Subtitle, this.rules.SheetSubtitleHeight, TextAlignmentEnum.CenterCenter, this.rules);
|
|
|
subtitle.Label.colorDefault = defaultColorTitle;
|
|
|
this.graphicalMusicSheet.Subtitle = subtitle;
|
|
|
subtitle.setLabelPositionAndShapeBorders();
|
|
|
- } else if (!EngravingRules.Rules.RenderSubtitle) {
|
|
|
+ } else if (!this.rules.RenderSubtitle) {
|
|
|
this.graphicalMusicSheet.Subtitle = undefined;
|
|
|
}
|
|
|
- if (musicSheet.Composer !== undefined && EngravingRules.Rules.RenderComposer) {
|
|
|
- const composer: GraphicalLabel = new GraphicalLabel(musicSheet.Composer, this.rules.SheetComposerHeight, TextAlignmentEnum.RightCenter);
|
|
|
+ if (musicSheet.Composer !== undefined && this.rules.RenderComposer) {
|
|
|
+ const composer: GraphicalLabel = new GraphicalLabel(
|
|
|
+ musicSheet.Composer, this.rules.SheetComposerHeight, TextAlignmentEnum.RightCenter, this.rules);
|
|
|
composer.Label.colorDefault = defaultColorTitle;
|
|
|
this.graphicalMusicSheet.Composer = composer;
|
|
|
composer.setLabelPositionAndShapeBorders();
|
|
|
- } else if (!EngravingRules.Rules.RenderComposer) {
|
|
|
+ } else if (!this.rules.RenderComposer) {
|
|
|
this.graphicalMusicSheet.Composer = undefined;
|
|
|
}
|
|
|
- if (musicSheet.Lyricist !== undefined && EngravingRules.Rules.RenderLyricist) {
|
|
|
- const lyricist: GraphicalLabel = new GraphicalLabel(musicSheet.Lyricist, this.rules.SheetAuthorHeight, TextAlignmentEnum.LeftCenter);
|
|
|
+ if (musicSheet.Lyricist !== undefined && this.rules.RenderLyricist) {
|
|
|
+ const lyricist: GraphicalLabel = new GraphicalLabel(
|
|
|
+ musicSheet.Lyricist, this.rules.SheetAuthorHeight, TextAlignmentEnum.LeftCenter, this.rules);
|
|
|
lyricist.Label.colorDefault = defaultColorTitle;
|
|
|
this.graphicalMusicSheet.Lyricist = lyricist;
|
|
|
lyricist.setLabelPositionAndShapeBorders();
|
|
|
- } else if (!EngravingRules.Rules.RenderLyricist) {
|
|
|
+ } else if (!this.rules.RenderLyricist) {
|
|
|
this.graphicalMusicSheet.Lyricist = undefined;
|
|
|
}
|
|
|
}
|
|
@@ -1725,7 +1728,7 @@ export abstract class MusicSheetCalculator {
|
|
|
}
|
|
|
|
|
|
protected calculatePageLabels(page: GraphicalMusicPage): void {
|
|
|
- if (EngravingRules.Rules.RenderSingleHorizontalStaffline) {
|
|
|
+ if (this.rules.RenderSingleHorizontalStaffline) {
|
|
|
page.PositionAndShape.BorderRight = page.PositionAndShape.Size.width;
|
|
|
page.PositionAndShape.calculateBoundingBox();
|
|
|
this.graphicalMusicSheet.ParentMusicSheet.pageWidth = page.PositionAndShape.Size.width;
|
|
@@ -2045,7 +2048,7 @@ export abstract class MusicSheetCalculator {
|
|
|
}
|
|
|
// if there are no staffEntries in this measure, create a rest for the whole measure:
|
|
|
// check OSMDOptions.fillEmptyMeasuresWithWholeRest
|
|
|
- if (EngravingRules.Rules.FillEmptyMeasuresWithWholeRest >= 1) { // fill measures with no notes given with whole rests, visible (1) or invisible (2)
|
|
|
+ if (this.rules.FillEmptyMeasuresWithWholeRest >= 1) { // fill measures with no notes given with whole rests, visible (1) or invisible (2)
|
|
|
if (measure.staffEntries.length === 0) {
|
|
|
const sourceStaffEntry: SourceStaffEntry = new SourceStaffEntry(
|
|
|
new VerticalSourceStaffEntryContainer(measure.parentSourceMeasure,
|
|
@@ -2054,7 +2057,7 @@ export abstract class MusicSheetCalculator {
|
|
|
staff);
|
|
|
const voiceEntry: VoiceEntry = new VoiceEntry(new Fraction(0, 1), staff.Voices[0], sourceStaffEntry);
|
|
|
const note: Note = new Note(voiceEntry, sourceStaffEntry, Fraction.createFromFraction(sourceMeasure.Duration), undefined);
|
|
|
- note.PrintObject = EngravingRules.Rules.FillEmptyMeasuresWithWholeRest === FillEmptyMeasuresWithWholeRests.YesVisible;
|
|
|
+ note.PrintObject = this.rules.FillEmptyMeasuresWithWholeRest === FillEmptyMeasuresWithWholeRests.YesVisible;
|
|
|
// don't display whole rest that wasn't given in XML, only for layout/voice completion
|
|
|
voiceEntry.Notes.push(note);
|
|
|
const graphicalStaffEntry: GraphicalStaffEntry = MusicSheetCalculator.symbolFactory.createStaffEntry(sourceStaffEntry, measure);
|
|
@@ -2446,7 +2449,8 @@ export abstract class MusicSheetCalculator {
|
|
|
* @param {number} y
|
|
|
*/
|
|
|
private calculateSingleDashForLyricWord(staffLine: StaffLine, startX: number, endX: number, y: number): void {
|
|
|
- const dash: GraphicalLabel = new GraphicalLabel(new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom);
|
|
|
+ const dash: GraphicalLabel = new GraphicalLabel(
|
|
|
+ new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom, this.rules);
|
|
|
dash.setLabelPositionAndShapeBorders();
|
|
|
staffLine.LyricsDashes.push(dash);
|
|
|
if (this.staffLinesWithLyricWords.indexOf(staffLine) === -1) {
|
|
@@ -2560,7 +2564,8 @@ export abstract class MusicSheetCalculator {
|
|
|
* @returns {number}
|
|
|
*/
|
|
|
private calculateRightAndLeftDashesForLyricWord(staffLine: StaffLine, startX: number, endX: number, y: number): number {
|
|
|
- const leftDash: GraphicalLabel = new GraphicalLabel(new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom);
|
|
|
+ const leftDash: GraphicalLabel = new GraphicalLabel(
|
|
|
+ new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom, this.rules);
|
|
|
leftDash.setLabelPositionAndShapeBorders();
|
|
|
staffLine.LyricsDashes.push(leftDash);
|
|
|
if (this.staffLinesWithLyricWords.indexOf(staffLine) === -1) {
|
|
@@ -2569,7 +2574,8 @@ export abstract class MusicSheetCalculator {
|
|
|
leftDash.PositionAndShape.Parent = staffLine.PositionAndShape;
|
|
|
const leftDashRelative: PointF2D = new PointF2D(startX, y);
|
|
|
leftDash.PositionAndShape.RelativePosition = leftDashRelative;
|
|
|
- const rightDash: GraphicalLabel = new GraphicalLabel(new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom);
|
|
|
+ const rightDash: GraphicalLabel = new GraphicalLabel(
|
|
|
+ new Label("-"), this.rules.LyricsHeight, TextAlignmentEnum.CenterBottom, this.rules);
|
|
|
rightDash.setLabelPositionAndShapeBorders();
|
|
|
staffLine.LyricsDashes.push(rightDash);
|
|
|
rightDash.PositionAndShape.Parent = staffLine.PositionAndShape;
|
|
@@ -2579,8 +2585,8 @@ export abstract class MusicSheetCalculator {
|
|
|
}
|
|
|
|
|
|
private calculateDynamicExpressions(): void {
|
|
|
- const maxIndex: number = Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length - 1, EngravingRules.Rules.MaxMeasureToDrawIndex);
|
|
|
- const minIndex: number = Math.min(EngravingRules.Rules.MinMeasureToDrawIndex, this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);
|
|
|
+ const maxIndex: number = Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length - 1, this.rules.MaxMeasureToDrawIndex);
|
|
|
+ const minIndex: number = Math.min(this.rules.MinMeasureToDrawIndex, this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length);
|
|
|
for (let i: number = minIndex; i <= maxIndex; i++) {
|
|
|
const sourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[i];
|
|
|
for (let j: number = 0; j < sourceMeasure.StaffLinkedExpressions.length; j++) {
|
|
@@ -2661,8 +2667,8 @@ export abstract class MusicSheetCalculator {
|
|
|
}
|
|
|
|
|
|
private calculateTempoExpressions(): void {
|
|
|
- const maxIndex: number = Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length - 1, EngravingRules.Rules.MaxMeasureToDrawIndex);
|
|
|
- const minIndex: number = EngravingRules.Rules.MinMeasureToDrawIndex;
|
|
|
+ const maxIndex: number = Math.min(this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures.length - 1, this.rules.MaxMeasureToDrawIndex);
|
|
|
+ const minIndex: number = this.rules.MinMeasureToDrawIndex;
|
|
|
for (let i: number = minIndex; i <= maxIndex; i++) {
|
|
|
const sourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.SourceMeasures[i];
|
|
|
for (let j: number = 0; j < sourceMeasure.TempoExpressions.length; j++) {
|