Преглед изворни кода

slight refactoring of staff measure.

Matthias пре 9 година
родитељ
комит
ed5154ea43

+ 14 - 9
src/MusicalScore/Graphical/StaffMeasure.ts

@@ -16,21 +16,26 @@ import {BoundingBox} from "./BoundingBox";
 export class StaffMeasure extends GraphicalObject {
     protected firstInstructionStaffEntry: GraphicalStaffEntry;
     protected lastInstructionStaffEntry: GraphicalStaffEntry;
-    private staff: Staff;
+    private parentStaff: Staff;
     private measureNumber: number = -1;
     private parentStaffLine: StaffLine;
-    constructor(staff: Staff = null, staffLine: StaffLine = null, parentSourceMeasure: SourceMeasure = null) {
-        this.staff = staff;
+    
+    constructor(staff: Staff = null, parentSourceMeasure: SourceMeasure = null, staffLine: StaffLine = null) {
+        this.parentStaff = staff;
         this.ParentSourceMeasure = parentSourceMeasure;
         this.parentStaffLine = staffLine;
-        if (staffLine != null)
-            this.staff = staffLine.ParentStaff;
+        if (staffLine != null) {
+            this.parentStaff = staffLine.ParentStaff;
+            this.PositionAndShape = new BoundingBox(staffLine.PositionAndShape, this);
+        }
+        else {
+            this.PositionAndShape = new BoundingBox(this);
+        }
+        this.PositionAndShape.BorderBottom = 4;
         if (this.ParentSourceMeasure != null)
             this.measureNumber = this.ParentSourceMeasure.MeasureNumber;
+
         this.StaffEntries = [];
-        if (staffLine != null)
-            this.PositionAndShape = new BoundingBox(staffLine.PositionAndShape, this);
-        else this.PositionAndShape = new BoundingBox(this);
     }
     public ParentSourceMeasure: SourceMeasure;
     public StaffEntries: GraphicalStaffEntry[];
@@ -41,7 +46,7 @@ export class StaffMeasure extends GraphicalObject {
     public EndInstructionsWidth: number;
     public hasError: boolean;
     public get ParentStaff(): Staff {
-        return this.staff;
+        return this.parentStaff;
     }
     public get MeasureNumber(): number {
         return this.measureNumber;

+ 18 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -23,6 +23,7 @@ import {LyricWord} from "../../VoiceData/Lyrics/LyricsWord";
 import {OrnamentContainer} from "../../VoiceData/OrnamentContainer";
 import {ArticulationEnum} from "../../VoiceData/VoiceEntry";
 import {Tuplet} from "../../VoiceData/Tuplet";
+import {VexFlowMeasure} from "./VexFlowMeasure";
 export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
     constructor() {
         super(new VexFlowGraphicalSymbolFactory());
@@ -41,8 +42,24 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         this.graphicalMusicSheet.MusicPages[0].PositionAndShape.BorderMarginBottom += 9;
         GraphicalMusicSheet.transformRelativeToAbsolutePosition(this.graphicalMusicSheet);
     }
+
+    /**
+     * Calculates the x layout of the staff entries within the staff measures belonging to one source measure.
+     * All staff entries are x-aligned throughout all vertically aligned staff measures.
+     * This method is called within calculateXLayout.
+     * The staff entries are aligned with minimum needed x distances.
+     * The MinimumStaffEntriesWidth of every measure will be set - needed for system building.
+     * @param measures
+     */
     protected calculateMeasureXLayout(measures: StaffMeasure[]): number {
-        throw new NotImplementedException();
+        // 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;
+
+
+        }
     }
 
     /**