|
@@ -11,19 +11,18 @@ import {VexFlowStaffEntry} from "./VexFlowStaffEntry";
|
|
//import {Fraction} from "../../../Common/DataObjects/fraction";
|
|
//import {Fraction} from "../../../Common/DataObjects/fraction";
|
|
|
|
|
|
import Vex = require("vexflow");
|
|
import Vex = require("vexflow");
|
|
-import StaveModifier = Vex.Flow.StaveModifier;
|
|
|
|
|
|
|
|
export class VexFlowMeasure extends StaffMeasure {
|
|
export class VexFlowMeasure extends StaffMeasure {
|
|
constructor(staff: Staff, staffLine: StaffLine = undefined, sourceMeasure: SourceMeasure = undefined) {
|
|
constructor(staff: Staff, staffLine: StaffLine = undefined, sourceMeasure: SourceMeasure = undefined) {
|
|
super(staff, sourceMeasure, staffLine);
|
|
super(staff, sourceMeasure, staffLine);
|
|
- // this.MinimumStaffEntriesWidth =
|
|
|
|
|
|
+ this.minimumStaffEntriesWidth = -1;
|
|
this.stave = new Vex.Flow.Stave(0, 0, 0);
|
|
this.stave = new Vex.Flow.Stave(0, 0, 0);
|
|
this.voices = {};
|
|
this.voices = {};
|
|
//this.duration = this.parentSourceMeasure.Duration;
|
|
//this.duration = this.parentSourceMeasure.Duration;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public voices: { [voiceID: number]: Vex.Flow.Voice; };
|
|
private stave: Vex.Flow.Stave;
|
|
private stave: Vex.Flow.Stave;
|
|
- private voices: { [voiceID: number]: Vex.Flow.Voice; };
|
|
|
|
//private duration: Fraction;
|
|
//private duration: Fraction;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -169,6 +168,17 @@ export class VexFlowMeasure extends StaffMeasure {
|
|
// TODO
|
|
// TODO
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public draw(canvas: HTMLCanvasElement): void {
|
|
|
|
+ let renderer: Vex.Flow.Renderer = new Vex.Flow.Renderer(canvas, Vex.Flow.Renderer.Backends.CANVAS);
|
|
|
|
+ let ctx: any = renderer.getContext();
|
|
|
|
+ this.stave.setContext(ctx).draw();
|
|
|
|
+ for (let voiceID in this.voices) {
|
|
|
|
+ if (this.voices.hasOwnProperty(voiceID)) {
|
|
|
|
+ this.voices[voiceID].draw(ctx, this.stave);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private increaseBeginInstructionWidth(): void {
|
|
private increaseBeginInstructionWidth(): void {
|
|
let modifiers: Vex.Flow.StaveModifier[] = this.stave.getModifiers();
|
|
let modifiers: Vex.Flow.StaveModifier[] = this.stave.getModifiers();
|
|
let modifier: Vex.Flow.StaveModifier = modifiers[modifiers.length - 1];
|
|
let modifier: Vex.Flow.StaveModifier = modifiers[modifiers.length - 1];
|