Procházet zdrojové kódy

refactor: create EngravingRule for ChordSymbol xSpacing (#599)

sschmid před 5 roky
rodič
revize
8707b96b5b

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

@@ -89,6 +89,7 @@ export class EngravingRules {
     private betweenDotsDistance: number;
     private ornamentAccidentalScalingFactor: number;
     private chordSymbolTextHeight: number;
+    private chordSymbolXSpacing: number;
     private chordSymbolYOffset: number;
     private fingeringLabelFontHeight: number;
     private measureNumberLabelHeight: number;
@@ -315,6 +316,7 @@ export class EngravingRules {
         this.betweenDotsDistance = 0.8;
         this.ornamentAccidentalScalingFactor = 0.65;
         this.chordSymbolTextHeight = 2.0;
+        this.chordSymbolXSpacing = 1.0;
         this.chordSymbolYOffset = 2.0;
         this.fingeringLabelFontHeight = 1.7;
 
@@ -887,6 +889,12 @@ export class EngravingRules {
     public set ChordSymbolTextHeight(value: number) {
         this.chordSymbolTextHeight = value;
     }
+    public get ChordSymbolXSpacing(): number {
+        return this.chordSymbolXSpacing;
+    }
+    public set ChordSymbolXSpacing(value: number) {
+        this.chordSymbolXSpacing = value;
+    }
     public get ChordSymbolYOffset(): number {
         return this.chordSymbolYOffset;
     }

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

@@ -157,7 +157,7 @@ export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory {
      */
     public createChordSymbols(sourceStaffEntry: SourceStaffEntry, graphicalStaffEntry: GraphicalStaffEntry, transposeHalftones: number): void {
         let xShift: number = 0;
-        const chordSymbolSpacing: number = 1; // TODO add engravingrules variable, check for available space until next staffEntry
+        const chordSymbolSpacing: number = EngravingRules.Rules.ChordSymbolXSpacing;
         for (const chordSymbolContainer of sourceStaffEntry.ChordContainers) {
             const graphicalChordSymbolContainer: GraphicalChordSymbolContainer =
               new GraphicalChordSymbolContainer(chordSymbolContainer,
@@ -167,6 +167,7 @@ export class VexFlowGraphicalSymbolFactory implements IGraphicalSymbolFactory {
             const graphicalLabel: GraphicalLabel = graphicalChordSymbolContainer.GetGraphicalLabel;
             graphicalLabel.PositionAndShape.RelativePosition.y -= EngravingRules.Rules.ChordSymbolYOffset;
             graphicalLabel.PositionAndShape.RelativePosition.x += xShift;
+            // TODO check for available space until next staffEntry or chord symbol (x direction)
             graphicalLabel.setLabelPositionAndShapeBorders();
             graphicalChordSymbolContainer.PositionAndShape.calculateBoundingBox();
             graphicalStaffEntry.graphicalChordContainers.push(graphicalChordSymbolContainer);