Procházet zdrojové kódy

fix(Tabs): by default, don't draw tuplet numbers in tabs (#805)

fix #805
add EngravingRules.TupletNumbersInTabs (boolean, default false)

(there was no sample available for testing)
sschmid před 4 roky
rodič
revize
89a9f0f5ab

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

@@ -116,6 +116,8 @@ export class EngravingRules {
     private tupletNumberYOffset: number;
     private labelMarginBorderFactor: number;
     private tupletVerticalLineLength: number;
+    private tupletNumbersInTabs: boolean;
+
     private repetitionEndingLabelHeight: number;
     private repetitionEndingLabelXOffset: number;
     private repetitionEndingLabelYOffset: number;
@@ -378,6 +380,7 @@ export class EngravingRules {
         this.tupletNumberYOffset = 0.5;
         this.labelMarginBorderFactor = 0.1;
         this.tupletVerticalLineLength = 0.5;
+        this.tupletNumbersInTabs = false; // disabled by default, nonstandard in tabs, at least how we show them in non-tabs.
 
         // Slur and Tie variables
         this.bezierCurveStepSize = 1000;
@@ -1080,6 +1083,12 @@ export class EngravingRules {
     public set TupletVerticalLineLength(value: number) {
         this.tupletVerticalLineLength = value;
     }
+    public get TupletNumbersInTabs(): boolean {
+        return this.tupletNumbersInTabs;
+    }
+    public set TupletNumbersInTabs(value: boolean) {
+        this.tupletNumbersInTabs = value;
+    }
     public get RepetitionEndingLabelHeight(): number {
         return this.repetitionEndingLabelHeight;
     }

+ 12 - 10
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -57,6 +57,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
         this.resetLayout();
     }
 
+    public isTabMeasure: boolean = false;
     /** octaveOffset according to active clef */
     public octaveOffset: number = 3;
     /** The VexFlow Voices in the measure */
@@ -556,17 +557,18 @@ export class VexFlowMeasure extends GraphicalMeasure {
                 beam.setContext(ctx).draw();
             }
         }
-        if (this.autoTupletVfBeams) {
-            for (const beam of this.autoTupletVfBeams) {
-                beam.setContext(ctx).draw();
+        if (!this.isTabMeasure || this.rules.TupletNumbersInTabs) {
+            if (this.autoTupletVfBeams) {
+                for (const beam of this.autoTupletVfBeams) {
+                    beam.setContext(ctx).draw();
+                }
             }
-        }
-
-        // Draw tuplets
-        for (const voiceID in this.vftuplets) {
-            if (this.vftuplets.hasOwnProperty(voiceID)) {
-                for (const tuplet of this.vftuplets[voiceID]) {
-                    tuplet.setContext(ctx).draw();
+            // Draw tuplets
+            for (const voiceID in this.vftuplets) {
+                if (this.vftuplets.hasOwnProperty(voiceID)) {
+                    for (const tuplet of this.vftuplets[voiceID]) {
+                        tuplet.setContext(ctx).draw();
+                    }
                 }
             }
         }

+ 4 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowTabMeasure.ts

@@ -14,6 +14,7 @@ import log from "loglevel";
 export class VexFlowTabMeasure extends VexFlowMeasure {
     constructor(staff: Staff, sourceMeasure: SourceMeasure = undefined, staffLine: StaffLine = undefined) {
         super(staff, sourceMeasure, staffLine);
+        this.isTabMeasure = true;
     }
 
     /**
@@ -47,7 +48,9 @@ export class VexFlowTabMeasure extends VexFlowMeasure {
             }
         }
 
-        this.finalizeTuplets();
+        if (this.rules.TupletNumbersInTabs) { // default false, don't show tuplets in tab measures
+            this.finalizeTuplets();
+        }
 
         const voices: Voice[] = this.getVoicesWithinMeasure();