Browse Source

fix(partAbbreviations): don't draw part abbreviations for solo parts, add option to not draw abbreviations

rename InstrumentNames to PartNames
sschmidTU 6 years ago
parent
commit
945d6a1728

+ 1 - 1
src/MusicalScore/Graphical/DrawingParameters.ts

@@ -175,7 +175,7 @@ export class DrawingParameters {
 
     public set DrawPartNames(value: boolean) {
         this.drawPartNames = value;
-        EngravingRules.Rules.RenderInstrumentNames = value;
+        EngravingRules.Rules.RenderPartNames = value;
     }
 
     public get FingeringPosition(): PlacementEnum {

+ 14 - 6
src/MusicalScore/Graphical/EngravingRules.ts

@@ -190,7 +190,8 @@ export class EngravingRules {
     private renderTitle: boolean;
     private renderSubtitle: boolean;
     private renderLyricist: boolean;
-    private renderInstrumentNames: boolean;
+    private renderPartNames: boolean;
+    private renderPartAbbreviations: boolean;
     private renderFingerings: boolean;
     private dynamicExpressionMaxDistance: number;
     private dynamicExpressionSpacer: number;
@@ -403,7 +404,8 @@ export class EngravingRules {
         this.renderTitle = true;
         this.renderSubtitle = true;
         this.renderLyricist = true;
-        this.renderInstrumentNames = true;
+        this.renderPartNames = true;
+        this.renderPartAbbreviations = true;
         this.renderFingerings = true;
         this.fingeringPosition = PlacementEnum.Left; // easier to get bounding box, and safer for vertical layout
         this.fingeringInsideStafflines = false;
@@ -1408,11 +1410,17 @@ export class EngravingRules {
     public set RenderLyricist(value: boolean) {
         this.renderLyricist = value;
     }
-    public get RenderInstrumentNames(): boolean {
-        return this.renderInstrumentNames;
+    public get RenderPartNames(): boolean {
+        return this.renderPartNames;
     }
-    public set RenderInstrumentNames(value: boolean) {
-        this.renderInstrumentNames = value;
+    public set RenderPartNames(value: boolean) {
+        this.renderPartNames = value;
+    }
+    public get RenderPartAbbreviations(): boolean {
+        return this.renderPartAbbreviations;
+    }
+    public set RenderPartAbbreviations(value: boolean) {
+        this.renderPartAbbreviations = value;
     }
     public get RenderFingerings(): boolean {
         return this.renderFingerings;

+ 1 - 1
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -1591,7 +1591,7 @@ export abstract class MusicSheetCalculator {
     }
 
     protected maxInstrNameLabelLength(): number {
-        if (!EngravingRules.Rules.RenderInstrumentNames) {
+        if (!EngravingRules.Rules.RenderPartNames) {
             return 0;
         }
         let maxLabelLength: number = 0.0;

+ 3 - 0
src/MusicalScore/Graphical/MusicSystem.ts

@@ -281,6 +281,9 @@ export abstract class MusicSystem extends GraphicalObject {
                 const instrument: Instrument = instruments[idx];
                 let instrNameLabel: Label;
                 if (this !== this.parent.MusicSystems[0]) {
+                    if (!EngravingRules.Rules.RenderPartAbbreviations || this.Parent.Parent.ParentMusicSheet.Instruments.length === 1) {
+                        return; // don't render part abbreviations if there's only one instrument/part (could be an option in the future)
+                    }
                     instrNameLabel = new Label(instrument.NameLabel.text[0] + ".", instrument.NameLabel.textAlignment, instrument.NameLabel.font);
                 } else {
                     instrNameLabel = instrument.NameLabel;

+ 1 - 1
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -230,7 +230,7 @@ export class MusicSystemBuilder {
     }
 
     private addSystemLabels(): void {
-        if (EngravingRules.Rules.RenderInstrumentNames) {
+        if (EngravingRules.Rules.RenderPartNames) {
             this.currentSystemParams.currentSystem.createMusicSystemLabel(
                 this.rules.InstrumentLabelTextHeight,
                 this.rules.SystemLabelsRightMargin,

+ 3 - 1
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -36,7 +36,9 @@ export interface IOSMDOptions {
     drawLyricist?: boolean;
     /** Whether to draw part (instrument) names. */
     drawPartNames?: boolean;
-    /** Whether to draw fingerings (only left to the note for now). Default true. */
+    /** Whether to draw part (instrument) name abbreviations each system after the first for non-solo parts. Default true. */
+    drawPartAbbreviations?: boolean;
+    /** Whether to draw fingerings (only left to the note for now). Default true (unless solo part). */
     drawFingerings?: boolean;
     /** Where to draw fingerings (left, right, above, below, auto).
      * Default left. Auto, above, below experimental (potential collisions because bounding box not correct)

+ 4 - 1
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -268,7 +268,10 @@ export class OpenSheetMusicDisplay {
             this.drawingParameters.drawCredits = options.drawCredits;
         }
         if (options.drawPartNames !== undefined) {
-            this.drawingParameters.DrawPartNames = options.drawPartNames;
+            this.drawingParameters.DrawPartNames = options.drawPartNames; // indirectly writes to EngravingRules
+        }
+        if (options.drawPartAbbreviations !== undefined) {
+            EngravingRules.Rules.RenderPartAbbreviations = options.drawPartAbbreviations;
         }
         if (options.drawFingerings === false) {
             EngravingRules.Rules.RenderFingerings = false;