Browse Source

feat(Options): Add option StretchLastSystemLine to stretch last system to full width (#842)

merge PR #847 by @bneumann

Note that this can also be fixed by a JustifiedMusicSystemBuilder. (justification = blocksatz)
Benjamin Giesinger 4 years ago
parent
commit
88d1a5a225

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

@@ -250,6 +250,7 @@ export class EngravingRules {
     private pageBackgroundColor: string; // vexflow-color-string (#FFFFFF). Default undefined/transparent.
     private renderSingleHorizontalStaffline: boolean;
     private restoreCursorAfterRerender: boolean;
+    private stretchLastSystemLine: boolean;
 
     private static fixStafflineBoundingBox: boolean; // TODO temporary workaround
 
@@ -510,6 +511,7 @@ export class EngravingRules {
         this.newSystemAtXMLNewSystemAttribute = false;
         this.newPageAtXMLNewPageAttribute = false;
         this.restoreCursorAfterRerender = true;
+        this.stretchLastSystemLine = false;
 
         EngravingRules.FixStafflineBoundingBox = false; // TODO temporary workaround
 
@@ -1828,6 +1830,12 @@ export class EngravingRules {
     public set RestoreCursorAfterRerender(value: boolean) {
         this.restoreCursorAfterRerender = value;
     }
+    public get StretchLastSystemLine(): boolean {
+        return this.stretchLastSystemLine;
+    }
+    public set StretchLastSystemLine(value: boolean) {
+        this.stretchLastSystemLine = value;
+    }
 
     public resetChordSymbolLabelTexts(chordtexts: Dictionary<ChordSymbolEnum, string>): Dictionary<ChordSymbolEnum, string> {
         chordtexts.setValue(ChordSymbolEnum.minor, "m");

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

@@ -141,7 +141,7 @@ export class MusicSystemBuilder {
                 this.updateActiveClefs(sourceMeasure, graphicalMeasures);
                 this.measureListIndex++;
                 if (sourceMeasureEndsPart) {
-                    this.finalizeCurrentAndCreateNewSystem(graphicalMeasures, true, false);
+                    this.finalizeCurrentAndCreateNewSystem(graphicalMeasures, !this.rules.StretchLastSystemLine, false);
                 }
                 prevMeasureEndsPart = sourceMeasureEndsPart;
             } else {
@@ -152,7 +152,7 @@ export class MusicSystemBuilder {
             }
         }
         if (this.currentSystemParams.systemMeasures.length > 0) {
-            this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length - 1], true, false);
+            this.finalizeCurrentAndCreateNewSystem(this.measureList[this.measureList.length - 1], !this.rules.StretchLastSystemLine, false);
         }
         return this.musicSystems;
     }

+ 4 - 0
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -203,6 +203,10 @@ export interface IOSMDOptions {
      *  Setting this is the same as setting osmd.EngravingRules.SoftmaxFactorVexFlow.
      */
     spacingFactorSoftmax?: number;
+    /**
+     * Set to true if the last system line should be streched across the whole page just as the other systems. Default is false
+     */
+    StretchLastSystemLine?: boolean;
 }
 
 export enum AlignRestOption {

+ 3 - 0
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -524,6 +524,9 @@ export class OpenSheetMusicDisplay {
         if (options.spacingFactorSoftmax !== undefined) {
             this.rules.SoftmaxFactorVexFlow = options.spacingFactorSoftmax;
         }
+        if (options.StretchLastSystemLine !== undefined) {
+            this.rules.StretchLastSystemLine = options.StretchLastSystemLine;
+        }
     }
 
     public setColoringMode(options: IOSMDOptions): void {