VexFlowMeasure.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import {StaffMeasure} from "../StaffMeasure";
  2. import {SourceMeasure} from "../../VoiceData/SourceMeasure";
  3. import {Staff} from "../../VoiceData/Staff";
  4. import {BoundingBox} from "../BoundingBox";
  5. import {StaffLine} from "../StaffLine";
  6. import {SystemLinesEnum} from "../SystemLinesEnum";
  7. import {ClefInstruction} from "../../VoiceData/Instructions/ClefInstruction";
  8. import {KeyInstruction} from "../../VoiceData/Instructions/KeyInstruction";
  9. import {RhythmInstruction} from "../../VoiceData/Instructions/RhythmInstruction";
  10. export class VexFlowMeasure extends StaffMeasure {
  11. constructor(staff: Staff, staffLine: StaffLine = undefined, sourceMeasure: SourceMeasure = undefined) {
  12. super(staff, staffLine, sourceMeasure);
  13. // this.MinimumStaffEntriesWidth =
  14. }
  15. /**
  16. * Reset all the geometric values and parameters of this measure and put it in an initialized state.
  17. * This is needed to evaluate a measure a second time by system builder.
  18. */
  19. public resetLayout(): void {
  20. this.beginInstructionsWidth = 0;
  21. }
  22. /**
  23. * returns the x-width of a given measure line.
  24. * @param line
  25. * @returns {SystemLinesEnum} the x-width
  26. */
  27. public getLineWidth(line: SystemLinesEnum): number {
  28. //SystemLinesEnum.
  29. return 5;
  30. }
  31. /**
  32. * adds the given clef to the begin of the measure.
  33. * This has to update/increase BeginInstructionsWidth.
  34. * @param clef
  35. */
  36. public addClefAtBegin(clef: ClefInstruction): void {
  37. this.beginInstructionsWidth += 20;
  38. }
  39. /**
  40. * adds the given key to the begin of the measure.
  41. * This has to update/increase BeginInstructionsWidth.
  42. * @param currentKey the new valid key.
  43. * @param previousKey the old cancelled key. Needed to show which accidentals are not valid any more.
  44. * @param currentClef the valid clef. Needed to put the accidentals on the right y-positions.
  45. */
  46. public addKeyAtBegin(currentKey: KeyInstruction, previousKey: KeyInstruction, currentClef: ClefInstruction): void {
  47. }
  48. /**
  49. * adds the given rhythm to the begin of the measure.
  50. * This has to update/increase BeginInstructionsWidth.
  51. * @param rhythm
  52. */
  53. public addRhythmAtBegin(rhythm: RhythmInstruction): void {
  54. }
  55. /**
  56. * adds the given clef to the end of the measure.
  57. * This has to update/increase EndInstructionsWidth.
  58. * @param clef
  59. */
  60. public addClefAtEnd(clef: ClefInstruction): void {
  61. }
  62. /**
  63. * This method sets the x-position relative to the staffline. (y-Position is always 0 relative to the staffline)
  64. * @param xPos
  65. */
  66. public setPositionInStaffline(xPos: number): void {
  67. }
  68. /**
  69. * Sets the overall x-width of the measure.
  70. * @param width
  71. */
  72. public setWidth(width: number): void {
  73. }
  74. /**
  75. * This method is called after the StaffEntriesScaleFactor has been set.
  76. * Here the final x-positions of the staff entries have to be set.
  77. * (multiply the minimal positions with the scaling factor, considering the BeginInstructionsWidth)
  78. */
  79. public layoutSymbols(): void {
  80. }
  81. }