Kaynağa Gözat

create EngravingRule for ChordSymbolYOffset

part of #418

refactor autoBeam tuplet handling -> more compact
sschmidTU 6 yıl önce
ebeveyn
işleme
2e769632a1

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

@@ -86,7 +86,7 @@ export class EngravingRules {
     private betweenDotsDistance: number;
     private ornamentAccidentalScalingFactor: number;
     private chordSymbolTextHeight: number;
-    //private chordSymbolYOffset: number;
+    private chordSymbolYOffset: number;
     private fingeringLabelFontHeight: number;
     private measureNumberLabelHeight: number;
     private measureNumberLabelOffset: number;
@@ -290,6 +290,7 @@ export class EngravingRules {
         this.betweenDotsDistance = 0.8;
         this.ornamentAccidentalScalingFactor = 0.65;
         this.chordSymbolTextHeight = 2.0;
+        this.chordSymbolYOffset = 2.0;
         this.fingeringLabelFontHeight = 1.7;
 
         // Tuplets, MeasureNumber and TupletNumber Labels
@@ -841,6 +842,12 @@ export class EngravingRules {
     public set ChordSymbolTextHeight(value: number) {
         this.chordSymbolTextHeight = value;
     }
+    public get ChordSymbolYOffset(): number {
+        return this.chordSymbolYOffset;
+    }
+    public set ChordSymbolYOffset(value: number) {
+        this.chordSymbolYOffset = value;
+    }
     public get FingeringLabelFontHeight(): number {
         return this.fingeringLabelFontHeight;
     }

+ 1 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowGraphicalSymbolFactory.ts

@@ -162,7 +162,7 @@ export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory {
                                           EngravingRules.Rules.ChordSymbolTextHeight,
                                           transposeHalftones);
       const graphicalLabel: GraphicalLabel = graphicalChordSymbolContainer.GetGraphicalLabel;
-      graphicalLabel.PositionAndShape.RelativePosition.y -= 2;
+      graphicalLabel.PositionAndShape.RelativePosition.y -= EngravingRules.Rules.ChordSymbolYOffset;
       graphicalLabel.setLabelPositionAndShapeBorders();
       graphicalChordSymbolContainer.PositionAndShape.calculateBoundingBox();
       graphicalStaffEntry.graphicalChordContainer = graphicalChordSymbolContainer;

+ 4 - 7
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -604,9 +604,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
         }
     }
 
-    /** Autobeams notes except beamedNotes, using Vexflow's Beam.generateBeams().
+    /** Automatically creates beams for notes except beamedNotes, using Vexflow's Beam.generateBeams().
      *  Takes options from EngravingRules.Rules.AutoBeamOptions.
-     * @param beamedNotes notes that will not be autobeamed (because they are already beamed)
+     * @param beamedNotes notes that will not be autobeamed (usually because they are already beamed)
      */
     private autoBeamNotes(beamedNotes: StemmableNote[]): void {
         const notesToAutoBeam: StemmableNote[] = [];
@@ -634,19 +634,16 @@ export class VexFlowMeasure extends GraphicalMeasure {
                 if (noteTuplet) {
                     if (currentTuplet === undefined) {
                         currentTuplet = noteTuplet;
-                        tupletNotesToAutoBeam.push(<StaveNote>(gve as VexFlowVoiceEntry).vfStaveNote);
                     } else {
-                        if (currentTuplet === noteTuplet) {
-                            tupletNotesToAutoBeam.push(<StaveNote>(gve as VexFlowVoiceEntry).vfStaveNote);
-                        } else { // new tuplet, finish old one
+                        if (currentTuplet !== noteTuplet) { // new tuplet, finish old one
                             if (tupletNotesToAutoBeam.length > 1) {
                                 this.autoTupletVfBeams.push(new Vex.Flow.Beam(tupletNotesToAutoBeam, true));
                             }
                             tupletNotesToAutoBeam = [];
                             currentTuplet = noteTuplet;
-                            tupletNotesToAutoBeam.push(<StaveNote>(gve as VexFlowVoiceEntry).vfStaveNote);
                         }
                     }
+                    tupletNotesToAutoBeam.push(<StaveNote>(gve as VexFlowVoiceEntry).vfStaveNote);
                     continue;
                 } else {
                     currentTuplet = undefined;