浏览代码

feat(Options): add drawLyrics option (#602)

part of #602
sschmid 5 年之前
父节点
当前提交
9d09586f53

+ 8 - 0
src/MusicalScore/Graphical/EngravingRules.ts

@@ -202,6 +202,7 @@ export class EngravingRules {
     private renderPartAbbreviations: boolean;
     private renderFingerings: boolean;
     private renderMeasureNumbers: boolean;
+    private renderLyrics: boolean;
     private dynamicExpressionMaxDistance: number;
     private dynamicExpressionSpacer: number;
     /** Position of fingering label in relation to corresponding note (left, right supported, above, below experimental) */
@@ -421,6 +422,7 @@ export class EngravingRules {
         this.renderPartAbbreviations = true;
         this.renderFingerings = true;
         this.renderMeasureNumbers = true;
+        this.renderLyrics = true;
         this.fingeringPosition = PlacementEnum.Left; // easier to get bounding box, and safer for vertical layout
         this.fingeringInsideStafflines = false;
 
@@ -1478,6 +1480,12 @@ export class EngravingRules {
     public set RenderMeasureNumbers(value: boolean) {
         this.renderMeasureNumbers = value;
     }
+    public get RenderLyrics(): boolean {
+        return this.renderLyrics;
+    }
+    public set RenderLyrics(value: boolean) {
+        this.renderLyrics = value;
+    }
     public get FingeringPosition(): PlacementEnum {
         return this.fingeringPosition;
     }

+ 13 - 9
src/MusicalScore/Graphical/MusicSheetDrawer.ts

@@ -295,14 +295,16 @@ export abstract class MusicSheetDrawer {
         for (const staffLine of musicSystem.StaffLines) {
             this.drawStaffLine(staffLine);
 
-            // draw lyric dashes
-            if (staffLine.LyricsDashes.length > 0) {
-                this.drawDashes(staffLine.LyricsDashes);
-            }
+            if (EngravingRules.Rules.RenderLyrics) {
+                // draw lyric dashes
+                if (staffLine.LyricsDashes.length > 0) {
+                    this.drawDashes(staffLine.LyricsDashes);
+                }
 
-            // draw lyric lines (e.g. LyricExtends: "dich,___")
-            if (staffLine.LyricLines.length > 0) {
-                this.drawLyricLines(staffLine.LyricLines, staffLine);
+                // draw lyric lines (e.g. LyricExtends: "dich,___")
+                if (staffLine.LyricLines.length > 0) {
+                    this.drawLyricLines(staffLine.LyricLines, staffLine);
+                }
             }
         }
         for (const systemLine of musicSystem.SystemLines) {
@@ -349,8 +351,10 @@ export abstract class MusicSheetDrawer {
             this.drawMeasure(measure);
         }
 
-        if (staffLine.LyricsDashes.length > 0) {
-            this.drawDashes(staffLine.LyricsDashes);
+        if (EngravingRules.Rules.RenderLyrics) {
+            if (staffLine.LyricsDashes.length > 0) {
+                this.drawDashes(staffLine.LyricsDashes);
+            }
         }
 
         this.drawOctaveShifts(staffLine);

+ 4 - 2
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer.ts

@@ -242,8 +242,10 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
         if (staffEntry.graphicalChordContainer !== undefined) {
             this.drawLabel(staffEntry.graphicalChordContainer.GetGraphicalLabel, <number>GraphicalLayers.Notes);
         }
-        if (staffEntry.LyricsEntries.length > 0) {
-            this.drawLyrics(staffEntry.LyricsEntries, <number>GraphicalLayers.Notes);
+        if (EngravingRules.Rules.RenderLyrics) {
+            if (staffEntry.LyricsEntries.length > 0) {
+                this.drawLyrics(staffEntry.LyricsEntries, <number>GraphicalLayers.Notes);
+            }
         }
     }
 

+ 2 - 0
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -70,6 +70,8 @@ export interface IOSMDOptions {
      * See the [measureNumberInterval] option, default is 2.
      */
     drawMeasureNumbers?: boolean;
+    /** Whether to draw lyrics (and their extensions and dashes). */
+    drawLyrics?: boolean;
     /** Where to draw fingerings (left, right, above, below, auto).
      * Default left. Auto, above, below experimental (potential collisions because bounding box not correct)
      */

+ 3 - 0
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -308,6 +308,9 @@ export class OpenSheetMusicDisplay {
         if (options.drawMeasureNumbers !== undefined) {
             EngravingRules.Rules.RenderMeasureNumbers = options.drawMeasureNumbers;
         }
+        if (options.drawLyrics !== undefined) {
+            EngravingRules.Rules.RenderLyrics = options.drawLyrics;
+        }
         if (options.measureNumberInterval !== undefined) {
             EngravingRules.Rules.MeasureNumberLabelOffset = options.measureNumberInterval;
         }