Forráskód Böngészése

refactor MusicSystemBuilder, samples: add barlines

Simon Schmid 5 éve
szülő
commit
d0f3e11045

+ 11 - 2
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -671,10 +671,17 @@ export class MusicSystemBuilder {
     }
 
     private getMeasureEndLine(): SystemLinesEnum {
+        let sourceMeasure: SourceMeasure = undefined;
+        try {
+            sourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
+        } finally {
+            // do nothing
+        }
+
         if (this.nextMeasureBeginsLineRepetition() && this.thisMeasureEndsLineRepetition()) {
             return SystemLinesEnum.DotsBoldBoldDots;
         }
-        if (this.thisMeasureEndsLineRepetition()) {
+        if (this.thisMeasureEndsLineRepetition() && (sourceMeasure && !sourceMeasure.endsPiece)) { // TODO right place to check endsPiece?
             return SystemLinesEnum.DotsThinBold;
         }
         // always end piece with final barline: not a good idea. user should be able to override final barline.
@@ -686,7 +693,9 @@ export class MusicSystemBuilder {
         if (this.nextMeasureHasKeyInstructionChange() || this.thisMeasureEndsWordRepetition() || this.nextMeasureBeginsWordRepetition()) {
             return SystemLinesEnum.DoubleThin;
         }
-        const sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
+        if (!sourceMeasure) {
+            return SystemLinesEnum.SingleThin;
+        }
         if (sourceMeasure.endingBarStyle === "regular") {
             return SystemLinesEnum.SingleThin;
         } else if (sourceMeasure.endingBarStyle === "dotted") {

+ 3 - 0
test/data/Schubert_An_die_Musik.xml

@@ -8546,6 +8546,9 @@
         <voice>1</voice>
         <type>quarter</type>
         </note>
+      <barline location="right">
+        <bar-style>light-heavy</bar-style>
+      </barline>
       </measure>
     </part>
   </score-partwise>

+ 1 - 0
test/data/ScottJoplin_The_Entertainer.xml

@@ -20733,6 +20733,7 @@
         <type>eighth</type>
       </note>
       <barline location="right">
+        <bar-style>light-heavy</bar-style>
         <ending type="stop" number="2"/>
       </barline>
     </measure>