瀏覽代碼

feat(Instrument label abbreviations): Added instrument label abbreviations

#466
Benjamin Giesinger 6 年之前
父節點
當前提交
a67dc00e39

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

@@ -308,7 +308,7 @@ export abstract class MusicSheetDrawer {
         for (const systemLine of musicSystem.SystemLines) {
             this.drawSystemLineObject(systemLine);
         }
-        if (musicSystem === musicSystem.Parent.MusicSystems[0] && musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0]) {
+        if (musicSystem.Parent === musicSystem.Parent.Parent.MusicPages[0]) {
             for (const label of musicSystem.Labels) {
                 this.drawLabel(label, <number>GraphicalLayers.Notes);
             }

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

@@ -19,6 +19,7 @@ import {GraphicalMarkedArea} from "./GraphicalMarkedArea";
 import {SystemLine} from "./SystemLine";
 import {SystemLinePosition} from "./SystemLinePosition";
 import {Staff} from "../VoiceData/Staff";
+import { Label } from "../Label";
 
 /**
  * A MusicSystem contains the [[StaffLine]]s for all instruments, until a line break
@@ -274,12 +275,18 @@ export abstract class MusicSystem extends GraphicalObject {
      * @param labelMarginBorderFactor
      */
     public createMusicSystemLabel(instrumentLabelTextHeight: number, systemLabelsRightMargin: number, labelMarginBorderFactor: number): void {
-        if (this.parent === this.parent.Parent.MusicPages[0] && this === this.parent.MusicSystems[0]) {
+        if (this.parent === this.parent.Parent.MusicPages[0]) {
             const instruments: Instrument[] = this.parent.Parent.ParentMusicSheet.getVisibleInstruments();
             for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
                 const instrument: Instrument = instruments[idx];
+                let instrNameLabel: Label;
+                if (this !== this.parent.MusicSystems[0]) {
+                    instrNameLabel = new Label(instrument.NameLabel.text[0] + ".", instrument.NameLabel.textAlignment, instrument.NameLabel.font);
+                } else {
+                    instrNameLabel = instrument.NameLabel;
+                }
                 const graphicalLabel: GraphicalLabel = new GraphicalLabel(
-                    instrument.NameLabel, instrumentLabelTextHeight, TextAlignmentEnum.LeftCenter, this.boundingBox
+                    instrNameLabel, instrumentLabelTextHeight, TextAlignmentEnum.LeftCenter, this.boundingBox
                 );
                 graphicalLabel.setLabelPositionAndShapeBorders();
                 this.labels.setValue(graphicalLabel, instrument);
@@ -305,7 +312,7 @@ export abstract class MusicSystem extends GraphicalObject {
      * Set the Y-Positions for the MusicSystem's Labels.
      */
     public setMusicSystemLabelsYPosition(): void {
-        if (this.parent === this.parent.Parent.MusicPages[0] && this === this.parent.MusicSystems[0]) {
+        if (this.parent === this.parent.Parent.MusicPages[0]) {
             this.labels.forEach((key: GraphicalLabel, value: Instrument): void => {
                 let ypositionSum: number = 0;
                 let staffCounter: number = 0;

+ 12 - 7
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -65,13 +65,7 @@ export class MusicSystemBuilder {
         // the first System - create also its Labels
         this.currentSystemParams.currentSystem = this.initMusicSystem();
         this.layoutSystemStaves();
-        if (EngravingRules.Rules.RenderInstrumentNames) {
-            this.currentSystemParams.currentSystem.createMusicSystemLabel(
-                this.rules.InstrumentLabelTextHeight,
-                this.rules.SystemLabelsRightMargin,
-                this.rules.LabelMarginBorderFactor
-            );
-        }
+        this.addSystemLabels();
         this.currentPageHeight += this.currentSystemParams.currentSystem.PositionAndShape.RelativePosition.y;
 
         let numberOfMeasures: number = 0;
@@ -191,6 +185,7 @@ export class MusicSystemBuilder {
         if (this.measureListIndex < this.measureList.length) {
             this.currentSystemParams.currentSystem = this.initMusicSystem();
             this.layoutSystemStaves();
+            this.addSystemLabels();
         }
     }
 
@@ -234,6 +229,16 @@ export class MusicSystemBuilder {
         this.currentSystemParams.systemMeasureIndex++;
     }
 
+    private addSystemLabels(): void {
+        if (EngravingRules.Rules.RenderInstrumentNames) {
+            this.currentSystemParams.currentSystem.createMusicSystemLabel(
+                this.rules.InstrumentLabelTextHeight,
+                this.rules.SystemLabelsRightMargin,
+                this.rules.LabelMarginBorderFactor
+            );
+        }
+    }
+
     /**
      * Create a new [[GraphicalMusicPage]]
      * (for now only one long page is used per music sheet, as we scroll down and have no page flips)