浏览代码

Linting...

Andrea Condoluci 9 年之前
父节点
当前提交
09c47382ce

+ 7 - 7
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -1,4 +1,4 @@
-import {MusicSheet} from "../MusicSheet";
+import {MusicSheet} from "../MusicSheet";
 import {SourceMeasure} from "../VoiceData/SourceMeasure";
 import {StaffMeasure} from "./StaffMeasure";
 import {GraphicalMusicPage} from "./GraphicalMusicPage";
@@ -43,8 +43,8 @@ export class GraphicalMusicSheet {
     private composer: GraphicalLabel;
     private lyricist: GraphicalLabel;
     private scoreFollowingLines: GraphicalLine[] = [];
-    private maxAllowedSystemWidth: number;
-    private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
+    private minAllowedSystemWidth: number;
+    //private systemImages: Dictionary<MusicSystem, SystemImageProperties> = new Dictionary<MusicSystem, SystemImageProperties>();
     private numberOfStaves: number;
     private leadSheet: boolean = false;
 
@@ -120,12 +120,12 @@ export class GraphicalMusicSheet {
         return this.scoreFollowingLines;
     }
 
-    public get MaxAllowedSystemWidth(): number {
-        return this.maxAllowedSystemWidth;
+    public get MinAllowedSystemWidth(): number {
+        return this.minAllowedSystemWidth;
     }
 
-    public set MaxAllowedSystemWidth(value: number) {
-        this.maxAllowedSystemWidth = value;
+    public set MinAllowedSystemWidth(value: number) {
+        this.minAllowedSystemWidth = value;
     }
 
     public get SystemImages(): Dictionary<MusicSystem, SystemImageProperties> {

+ 33 - 12
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -1,4 +1,4 @@
-import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
+import {GraphicalStaffEntry} from "./GraphicalStaffEntry";
 import {StaffLine} from "./StaffLine";
 import {GraphicalMusicSheet} from "./GraphicalMusicSheet";
 import {EngravingRules} from "./EngravingRules";
@@ -152,16 +152,21 @@ export class MusicSheetCalculator {
     }
 
     public calculateXLayout(graphicalMusicSheet: GraphicalMusicSheet, maxInstrNameLabelLength: number): void {
-        let maxLength: number = 0;
+        let minLength: number = 0;
         let maxInstructionsLength: number = this.rules.MaxInstructionsConstValue;
         if (this.graphicalMusicSheet.MeasureList.length > 0) {
-            maxLength = this.calculateMeasureXLayout(this.graphicalMusicSheet.MeasureList[0]) * 1.2 + maxInstrNameLabelLength + maxInstructionsLength;
+            let measures: StaffMeasure[] = this.graphicalMusicSheet.MeasureList[0];
+            let minimumStaffEntriesWidth: number = this.calculateMeasureXLayout(measures);
+            MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(measures, minimumStaffEntriesWidth);
+            minLength = minimumStaffEntriesWidth * 1.2 + maxInstrNameLabelLength + maxInstructionsLength;
             for (let i: number = 1; i < this.graphicalMusicSheet.MeasureList.length; i++) {
-                let measures: StaffMeasure[] = this.graphicalMusicSheet.MeasureList[i];
-                maxLength = Math.max(maxLength, this.calculateMeasureXLayout(measures) * 1.2 + maxInstructionsLength);
+                measures = this.graphicalMusicSheet.MeasureList[i];
+                minimumStaffEntriesWidth = this.calculateMeasureXLayout(measures);
+                MusicSheetCalculator.setMeasuresMinStaffEntriesWidth(measures, minimumStaffEntriesWidth);
+                minLength = Math.max(minLength, minimumStaffEntriesWidth * 1.2 + maxInstructionsLength);
             }
         }
-        this.graphicalMusicSheet.MaxAllowedSystemWidth = maxLength;
+        this.graphicalMusicSheet.MinAllowedSystemWidth = minLength;
     }
 
     protected calculateMeasureXLayout(measures: StaffMeasure[]): number {
@@ -472,7 +477,9 @@ export class MusicSheetCalculator {
                     for (let idx4: number = 0, len4: number = staffLine.Measures.length; idx4 < len4; ++idx4) {
                         let graphicalMeasure: StaffMeasure = staffLine.Measures[idx4];
                         if (graphicalMeasure.FirstInstructionStaffEntry !== undefined) {
-                            let index: number = graphicalMeasure.PositionAndShape.ChildElements.indexOf(graphicalMeasure.FirstInstructionStaffEntry.PositionAndShape);
+                            let index: number = graphicalMeasure.PositionAndShape.ChildElements.indexOf(
+                                graphicalMeasure.FirstInstructionStaffEntry.PositionAndShape
+                            );
                             if (index > -1) {
                                 graphicalMeasure.PositionAndShape.ChildElements.splice(index, 1);
                             }
@@ -480,7 +487,9 @@ export class MusicSheetCalculator {
                             graphicalMeasure.beginInstructionsWidth = 0.0;
                         }
                         if (graphicalMeasure.LastInstructionStaffEntry !== undefined) {
-                            let index: number = graphicalMeasure.PositionAndShape.ChildElements.indexOf(graphicalMeasure.LastInstructionStaffEntry.PositionAndShape);
+                            let index: number = graphicalMeasure.PositionAndShape.ChildElements.indexOf(
+                                graphicalMeasure.LastInstructionStaffEntry.PositionAndShape
+                            );
                             if (index > -1) {
                                 graphicalMeasure.PositionAndShape.ChildElements.splice(index, 1);
                             }
@@ -704,7 +713,7 @@ export class MusicSheetCalculator {
                             let gse: GraphicalStaffEntry = measure.staffEntries[0];
                             if (gse.notes.length > 0 && gse.notes[0].length > 0) {
                                 let graphicalNote: GraphicalNote = gse.notes[0][0];
-                                if (graphicalNote.sourceNote.Pitch === undefined && (new Fraction(1, 2)).lt(graphicalNote.sourceNote.Length)) {
+                                if (graphicalNote.sourceNote.Pitch === undefined && (new Fraction(1, 2)).lt(graphicalNote.sourceNote.length)) {
                                     this.layoutMeasureWithWholeRest(graphicalNote, gse, measure);
                                 }
                             }
@@ -809,7 +818,12 @@ export class MusicSheetCalculator {
         let posX: number = gse.PositionAndShape.RelativePosition.x + gse.parentMeasure.PositionAndShape.RelativePosition.x;
         return posX;
     }
-
+    private static setMeasuresMinStaffEntriesWidth(measures: StaffMeasure[], minimumStaffEntriesWidth: number): void {
+        for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
+            let measure: StaffMeasure = measures[idx];
+            measure.minimumStaffEntriesWidth = minimumStaffEntriesWidth;
+        }
+    }
     private createAccidentalCalculators(): AccidentalCalculator[] {
         let accidentalCalculators: AccidentalCalculator[] = [];
         let firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
@@ -865,7 +879,10 @@ export class MusicSheetCalculator {
         let openTuplets: Tuplet[] = [];
         let staffEntryLinks: StaffEntryLink[] = [];
         for (let staffIndex: number = 0; staffIndex < sourceMeasure.CompleteNumberOfStaves; staffIndex++) {
-            let measure: StaffMeasure = this.createGraphicalMeasure(sourceMeasure, tieTimestampListDictList[staffIndex], openTuplets, openBeams, accidentalCalculators[staffIndex], activeClefs, openOctaveShifts, openLyricWords, staffIndex, staffEntryLinks);
+            let measure: StaffMeasure = this.createGraphicalMeasure(
+                sourceMeasure, tieTimestampListDictList[staffIndex], openTuplets, openBeams,
+                accidentalCalculators[staffIndex], activeClefs, openOctaveShifts, openLyricWords, staffIndex, staffEntryLinks
+            );
             verticalMeasureList.push(measure);
         }
         this.graphicalMusicSheet.sourceToGraphicalMeasureLinks[sourceMeasure] = verticalMeasureList;
@@ -1386,7 +1403,11 @@ export class MusicSheetCalculator {
             for (let j: number = 0; j < sourceMeasure.StaffLinkedExpressions.length; j++) {
                 if (this.graphicalMusicSheet.MeasureList[i][j].ParentStaff.ParentInstrument.Visible) {
                     for (let k: number = 0; k < sourceMeasure.StaffLinkedExpressions[j].length; k++) {
-                        if (sourceMeasure.StaffLinkedExpressions[j][k].InstantaniousDynamic !== undefined || (sourceMeasure.StaffLinkedExpressions[j][k].StartingContinuousDynamic !== undefined && sourceMeasure.StaffLinkedExpressions[j][k].StartingContinuousDynamic.StartMultiExpression === sourceMeasure.StaffLinkedExpressions[j][k] && sourceMeasure.StaffLinkedExpressions[j][k].UnknownList.length === 0)) {
+                        if (sourceMeasure.StaffLinkedExpressions[j][k].InstantaniousDynamic !== undefined ||
+                            (sourceMeasure.StaffLinkedExpressions[j][k].StartingContinuousDynamic !== undefined &&
+                            sourceMeasure.StaffLinkedExpressions[j][k].StartingContinuousDynamic.StartMultiExpression ===
+                            sourceMeasure.StaffLinkedExpressions[j][k] && sourceMeasure.StaffLinkedExpressions[j][k].UnknownList.length === 0)
+                        ) {
                             this.calculateDynamicExpressionsForSingleMultiExpression(sourceMeasure.StaffLinkedExpressions[j][k], i, j);
                         }
                     }

+ 4 - 3
src/MusicalScore/Graphical/StaffLine.ts

@@ -72,9 +72,10 @@ export class StaffLine extends GraphicalObject {
     }
 
     public addActivitySymbolClickArea(): void {
-        var activitySymbol: StaffLineActivitySymbol = new StaffLineActivitySymbol(this);
-        var staffLinePsi: BoundingBox = this.PositionAndShape;
-        activitySymbol.PositionAndShape.RelativePosition = new PointF2D(staffLinePsi.RelativePosition.x + staffLinePsi.BorderRight + 0.5, staffLinePsi.RelativePosition.y + 0.5);
+        let activitySymbol: StaffLineActivitySymbol = new StaffLineActivitySymbol(this);
+        let staffLinePsi: BoundingBox = this.PositionAndShape;
+        activitySymbol.PositionAndShape.RelativePosition =
+            new PointF2D(staffLinePsi.RelativePosition.x + staffLinePsi.BorderRight + 0.5, staffLinePsi.RelativePosition.y + 0.5);
         this.parentMusicSystem.PositionAndShape.ChildElements.push(activitySymbol.PositionAndShape);
     }
 

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

@@ -144,7 +144,7 @@ export class StaffMeasure extends GraphicalObject {
         let duration: Fraction = new Fraction(0, 1);
         for (let idx: number = 0, len: number = this.staffEntries.length; idx < len; ++idx) {
             let graphicalStaffEntry: GraphicalStaffEntry = this.staffEntries[idx];
-            duration.Add(graphicalStaffEntry.findStaffEntryMinNoteLength());
+            duration.push(graphicalStaffEntry.findStaffEntryMinNoteLength());
         }
         return duration === this.parentSourceMeasure.Duration;
     }
@@ -193,7 +193,7 @@ export class StaffMeasure extends GraphicalObject {
                 for (let idx3: number = 0, len3: number = graphicalStaffEntry.notes.length; idx3 < len3; ++idx3) {
                     let graphicalNotes: GraphicalNote[] = graphicalStaffEntry.notes[idx3];
                     if (graphicalNotes.length > 0 && graphicalNotes[0].sourceNote.ParentVoiceEntry.ParentVoice === voice) {
-                        voiceDuration.Add(graphicalNotes[0].graphicalNoteLength);
+                        voiceDuration.push(graphicalNotes[0].graphicalNoteLength);
                     }
                 }
             }

+ 2 - 2
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -1,15 +1,15 @@
 import {StaffMeasure} from "../StaffMeasure";
 import {SourceMeasure} from "../../VoiceData/SourceMeasure";
 import {Staff} from "../../VoiceData/Staff";
-import {BoundingBox} from "../BoundingBox";
 import {StaffLine} from "../StaffLine";
 import {SystemLinesEnum} from "../SystemLinesEnum";
 import {ClefInstruction} from "../../VoiceData/Instructions/ClefInstruction";
 import {KeyInstruction} from "../../VoiceData/Instructions/KeyInstruction";
 import {RhythmInstruction} from "../../VoiceData/Instructions/RhythmInstruction";
+
 export class VexFlowMeasure extends StaffMeasure {
     constructor(staff: Staff, staffLine: StaffLine = undefined, sourceMeasure: SourceMeasure = undefined) {
-        super(staff, staffLine, sourceMeasure);
+        super(staff, sourceMeasure, staffLine);
         // this.MinimumStaffEntriesWidth =
     }
 

+ 4 - 10
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -1,4 +1,4 @@
-import {MusicSheetCalculator} from "../MusicSheetCalculator";
+import {MusicSheetCalculator} from "../MusicSheetCalculator";
 import {VexFlowGraphicalSymbolFactory} from "./VexFlowGraphicalSymbolFactory";
 import {GraphicalMusicSheet} from "../GraphicalMusicSheet";
 import {StaffMeasure} from "../StaffMeasure";
@@ -51,16 +51,11 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
      * The staff entries are aligned with minimum needed x distances.
      * The MinimumStaffEntriesWidth of every measure will be set - needed for system building.
      * @param measures
+     * @returns the minimum required x width of the source measure (=list of staff measures)
      */
     protected calculateMeasureXLayout(measures: StaffMeasure[]): number {
-        // set measure length and Borders
-        for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
-            //let measure: VexFlowMeasure  = <VexFlowMeasure>measures[idx];
-            // set Measure StaffEntriesLength (needed later to calculate the whole Measure Width)
-            //measure.MinimumStaffEntriesWidth = measureLength;
-
-
-        }
+        // layout the measures in x.
+        // return the minimum required x width of this vertically aligned measure set:
         return 0;
     }
 
@@ -82,7 +77,6 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         for (let idx: number = 0, len: number = measureList.length; idx < len; ++idx) {
             let gmlist: StaffMeasure[] = measureList[idx];
             numberOfStaffLines = Math.max(gmlist.length, numberOfStaffLines);
-            break;
         }
         if (numberOfStaffLines === 0) { return; }
         let musicSystemBuilder: MusicSystemBuilder = new MusicSystemBuilder();