Selaa lähdekoodia

feat(TimeSignatures): Can disable time signature for GraphicalMeasure

osmd issue 1150
with graphicalMeasure.ShowTimeSignature = false
sschmidTU 3 vuotta sitten
vanhempi
commit
70f77976d9

+ 1 - 0
src/MusicalScore/Graphical/GraphicalMeasure.ts

@@ -72,6 +72,7 @@ export abstract class GraphicalMeasure extends GraphicalObject {
     /** Used to show key, rhythm changes at the end of the system, has MeasureNumber < 0, because never set. */
     public IsExtraGraphicalMeasure: boolean;
     public ExtraGraphicalMeasurePreviousMeasure: GraphicalMeasure;
+    public ShowTimeSignature: boolean = true;
 
     public get ParentStaff(): Staff {
         return this.parentStaff;

+ 3 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -268,6 +268,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
             timeSig,
             VF.StaveModifier.Position.BEGIN
         );
+        if (!this.ShowTimeSignature) {
+            (timeSig as any).fillStyle = "#00000000"; // transparent. requires VexflowPatch
+        }
         this.updateInstructionWidth();
     }
 

+ 5 - 0
src/VexFlowPatch/src/timesignature.js

@@ -180,8 +180,13 @@ export class TimeSignature extends StaveModifier {
     this.timeSig.glyph.setStave(this.stave);
     this.timeSig.glyph.setContext(this.stave.context);
     this.placeGlyphOnLine(this.timeSig.glyph, this.stave, this.timeSig.line);
+    this.stave.context.save();
+    if (this.fillStyle) {
+      this.stave.context.setFillStyle(this.fillStyle);
+    }
     this.stave.context.openGroup("timesignature");
     this.timeSig.glyph.renderToStave(this.x);
     this.stave.context.closeGroup("timesignature");
+    this.stave.context.restore();
   }
 }