Bläddra i källkod

feat(options): add option to (not) draw slurs (#602)

sschmid 5 år sedan
förälder
incheckning
1333195fc6

+ 6 - 2
src/MusicalScore/Graphical/GraphicalVoiceEntry.ts

@@ -66,7 +66,10 @@ export class GraphicalVoiceEntry extends GraphicalObject {
             }
             if (!note.sourceNote.PrintObject) {
                 noteheadColor = transparentColor; // transparent
-            } else if (!noteheadColor) { // revert transparency after PrintObject was set to false, then true again
+            } else if (!noteheadColor // revert transparency after PrintObject was set to false, then true again
+                || noteheadColor === "#000000" // questionable, because you might want to set specific notes to black,
+                                               // but unfortunately some programs export everything explicitly as black
+                ) {
                 noteheadColor = EngravingRules.Rules.DefaultColorNotehead;
             }
 
@@ -122,7 +125,8 @@ export class GraphicalVoiceEntry extends GraphicalObject {
         let stemColor: string = EngravingRules.Rules.DefaultColorStem; // reset to black/default when coloring was disabled. maybe needed elsewhere too
         if (EngravingRules.Rules.ColoringEnabled) {
             stemColor = this.parentVoiceEntry.StemColor; // TODO: once coloringSetCustom gets stem color, respect it
-            if (!stemColor || EngravingRules.Rules.ColorStemsLikeNoteheads) {
+            if (!stemColor || EngravingRules.Rules.ColorStemsLikeNoteheads
+                || stemColor === "#000000") { // see above, noteheadColor === "#000000"
                 // condition could be even more fine-grained by only recoloring if there was no custom StemColor set. will be more complex though
                 if (noteheadColor) {
                     stemColor = noteheadColor;

+ 5 - 3
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -728,8 +728,10 @@ export abstract class MusicSheetCalculator {
             this.optimizeRestPlacement();
             // possible Displacement of RestNotes
             this.calculateStaffEntryArticulationMarks();
-            // calculate Ties
-            this.calculateTieCurves();
+            if (EngravingRules.Rules.DrawSlurs) { // technically we should separate slurs and ties, but shouldn't be relevant for now
+                // calculate Ties
+                this.calculateTieCurves();
+            }
         }
         // calculate Sky- and BottomLine
         // will have reasonable values only between ObjectsBorders (eg StaffEntries)
@@ -748,7 +750,7 @@ export abstract class MusicSheetCalculator {
             }
         }
         // calculate Slurs
-        if (!this.leadSheet) {
+        if (!this.leadSheet && EngravingRules.Rules.DrawSlurs) {
             this.calculateSlurs();
         }
         // calculate StaffEntry Ornaments

+ 3 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetDrawer.ts

@@ -83,7 +83,9 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
     protected drawStaffLine(staffLine: StaffLine): void {
         super.drawStaffLine(staffLine);
         const absolutePos: PointF2D = staffLine.PositionAndShape.AbsolutePosition;
-        this.drawSlurs(staffLine as VexFlowStaffLine, absolutePos);
+        if (EngravingRules.Rules.DrawSlurs) {
+            this.drawSlurs(staffLine as VexFlowStaffLine, absolutePos);
+        }
     }
 
     private drawSlurs(vfstaffLine: VexFlowStaffLine, absolutePos: PointF2D): void {

+ 2 - 0
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -77,6 +77,8 @@ export interface IOSMDOptions {
     drawMeasureNumbers?: boolean;
     /** Whether to draw lyrics (and their extensions and dashes). */
     drawLyrics?: boolean;
+    /** Whether to calculate extra slurs with bezier curves not covered by Vexflow slurs. Default true. */
+    drawSlurs?: 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

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