Преглед на файлове

feat(Chords): Add options for chord alignment, relative x offset (#948)

closes #948
sschmidTU преди 4 години
родител
ревизия
143899b742
променени са 2 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 4 0
      src/MusicalScore/Graphical/EngravingRules.ts
  2. 2 2
      src/MusicalScore/Graphical/GraphicalChordSymbolContainer.ts

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

@@ -102,6 +102,8 @@ export class EngravingRules {
     public BetweenDotsDistance: number;
     public OrnamentAccidentalScalingFactor: number;
     public ChordSymbolTextHeight: number;
+    public ChordSymbolTextAlignment: TextAlignmentEnum;
+    public ChordSymbolRelativeXOffset: number;
     public ChordSymbolXSpacing: number;
     public ChordOverlapAllowedIntoNextMeasure: number;
     public ChordSymbolYOffset: number;
@@ -401,6 +403,8 @@ export class EngravingRules {
         this.BetweenDotsDistance = 0.8;
         this.OrnamentAccidentalScalingFactor = 0.65;
         this.ChordSymbolTextHeight = 2.0;
+        this.ChordSymbolTextAlignment = TextAlignmentEnum.LeftBottom;
+        this.ChordSymbolRelativeXOffset = -1.0;
         this.ChordSymbolXSpacing = 1.0;
         this.ChordOverlapAllowedIntoNextMeasure = 0;
         this.ChordSymbolYOffset = 2.0;

+ 2 - 2
src/MusicalScore/Graphical/GraphicalChordSymbolContainer.ts

@@ -29,7 +29,7 @@ export class GraphicalChordSymbolContainer extends GraphicalObject {
     }
     private calculateLabel(textHeight: number, transposeHalftones: number, keyInstruction: KeyInstruction): void {
         const text: string = ChordSymbolContainer.calculateChordText(this.chordSymbolContainer, transposeHalftones, keyInstruction);
-        this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, TextAlignmentEnum.LeftBottom, this.rules, this.boundingBox);
-        this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(-1.0, 0.0);
+        this.graphicalLabel = new GraphicalLabel(new Label(text), textHeight, this.rules.ChordSymbolTextAlignment, this.rules, this.boundingBox);
+        this.graphicalLabel.PositionAndShape.RelativePosition = new PointF2D(this.rules.ChordSymbolRelativeXOffset, 0.0);
     }
 }