|
@@ -1036,12 +1036,14 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
let endStaffEntry: GraphicalStaffEntry = endMeasure.findGraphicalStaffEntryFromTimestamp(endTimeStamp);
|
|
|
if (!endStaffEntry) { // fix for rendering range set
|
|
|
endStaffEntry = endMeasure.staffEntries[endMeasure.staffEntries.length - 1];
|
|
|
+ // TODO can be undefined if no notes in end measure
|
|
|
}
|
|
|
graphicalPedal.setStartNote(startStaffEntry);
|
|
|
|
|
|
if (endStaffLine !== startStaffLine) {
|
|
|
if(graphicalPedal.pedalSymbol === MusicSymbol.PEDAL_SYMBOL){
|
|
|
graphicalPedal.setEndNote(endStaffEntry);
|
|
|
+ graphicalPedal.setEndMeasure(endMeasure);
|
|
|
graphicalPedal.ReleaseText = " ";
|
|
|
graphicalPedal.CalculateBoundingBox();
|
|
|
this.calculatePedalSkyBottomLine(graphicalPedal.startVfVoiceEntry, graphicalPedal.endVfVoiceEntry, graphicalPedal, startStaffLine);
|
|
@@ -1052,6 +1054,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
const firstNote: GraphicalStaffEntry = nextPedalFirstMeasure.staffEntries[0];
|
|
|
nextPedal.setStartNote(firstNote);
|
|
|
nextPedal.setEndNote(endStaffEntry);
|
|
|
+ graphicalPedal.setEndMeasure(endMeasure);
|
|
|
endStaffLine.Pedals.push(nextPedal);
|
|
|
nextPedal.CalculateBoundingBox();
|
|
|
nextPedal.DepressText = " ";
|
|
@@ -1063,6 +1066,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
}
|
|
|
const lastNoteOfFirstShift: GraphicalStaffEntry = lastMeasureOfFirstShift.staffEntries[lastMeasureOfFirstShift.staffEntries.length - 1];
|
|
|
graphicalPedal.setEndNote(lastNoteOfFirstShift);
|
|
|
+ graphicalPedal.setEndMeasure(endMeasure);
|
|
|
|
|
|
const systemsInBetweenCount: number = endStaffLine.ParentMusicSystem.Id - startStaffLine.ParentMusicSystem.Id;
|
|
|
if (systemsInBetweenCount > 0) {
|
|
@@ -1092,6 +1096,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
|
|
|
nextPedal.setStartNote(firstNote);
|
|
|
nextPedal.setEndNote(lastNote);
|
|
|
+ graphicalPedal.setEndMeasure(endMeasure);
|
|
|
nextPedalStaffline.Pedals.push(nextPedal);
|
|
|
nextPedal.CalculateBoundingBox();
|
|
|
this.calculatePedalSkyBottomLine(nextPedal.startVfVoiceEntry, nextPedal.endVfVoiceEntry, nextPedal, nextPedalStaffline);
|
|
@@ -1102,6 +1107,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
}
|
|
|
} else {
|
|
|
graphicalPedal.setEndNote(endStaffEntry);
|
|
|
+ graphicalPedal.setEndMeasure(endMeasure);
|
|
|
graphicalPedal.CalculateBoundingBox();
|
|
|
this.calculatePedalSkyBottomLine(graphicalPedal.startVfVoiceEntry, graphicalPedal.endVfVoiceEntry, graphicalPedal, startStaffLine);
|
|
|
}
|
|
@@ -1288,6 +1294,10 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
|
|
|
private calculatePedalSkyBottomLine(startVfVoiceEntry: VexFlowVoiceEntry, endVfVoiceEntry: VexFlowVoiceEntry,
|
|
|
vfPedal: VexFlowPedal, parentStaffline: StaffLine): void {
|
|
|
+ let endBbox: BoundingBox = endVfVoiceEntry?.PositionAndShape;
|
|
|
+ if (!endBbox) {
|
|
|
+ endBbox = vfPedal.endMeasure.PositionAndShape;
|
|
|
+ }
|
|
|
//Just for shorthand. Easier readability below
|
|
|
const PEDAL_STYLES_ENUM: any = Vex.Flow.PedalMarking.Styles;
|
|
|
const pedalMarking: any = vfPedal.getPedalMarking();
|
|
@@ -1309,7 +1319,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
if (vfPedal.EndSymbolPositionAndShape) {
|
|
|
//Width of the Ped. symbol
|
|
|
stopX = startX + 3.4;
|
|
|
- const startX2: number = endVfVoiceEntry.PositionAndShape.AbsolutePosition.x - pedalMarkingMarginXOffset;
|
|
|
+ const startX2: number = endBbox.AbsolutePosition.x - pedalMarkingMarginXOffset;
|
|
|
//Width of * symbol
|
|
|
const stopX2: number = startX2 + 1.5;
|
|
|
|
|
@@ -1320,7 +1330,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
if (!vfPedal.DepressText) {
|
|
|
footroom = Math.max(footroom, footroom2);
|
|
|
}
|
|
|
- if (startVfVoiceEntry.parentStaffEntry.parentMeasure !== endVfVoiceEntry.parentStaffEntry.parentMeasure) {
|
|
|
+ if (startVfVoiceEntry.parentStaffEntry.parentMeasure !== endVfVoiceEntry.parentStaffEntry.parentMeasure && vfPedal.endNote) {
|
|
|
//TODO: look into using the vexflow setLine instead of modifying the whole stave if possible
|
|
|
footroom = Math.max((vfPedal.endNote.getStave().options as any).bottom_text_position, footroom);
|
|
|
(vfPedal.endNote.getStave().options as any).bottom_text_position = footroom;
|
|
@@ -1333,14 +1343,14 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
case PEDAL_STYLES_ENUM.BRACKET_OPEN_END:
|
|
|
case PEDAL_STYLES_ENUM.BRACKET_OPEN_BOTH:
|
|
|
case PEDAL_STYLES_ENUM.MIXED_OPEN_END:
|
|
|
- stopX = endVfVoiceEntry.PositionAndShape.AbsolutePosition.x + endVfVoiceEntry.PositionAndShape.BorderRight - pedalMarkingMarginXOffset;
|
|
|
+ stopX = endBbox.AbsolutePosition.x + endBbox.BorderRight - pedalMarkingMarginXOffset;
|
|
|
break;
|
|
|
default:
|
|
|
- stopX = endVfVoiceEntry.PositionAndShape.AbsolutePosition.x + endVfVoiceEntry.PositionAndShape.BorderLeft - pedalMarkingMarginXOffset;
|
|
|
+ stopX = endBbox.AbsolutePosition.x + endBbox.BorderLeft - pedalMarkingMarginXOffset;
|
|
|
break;
|
|
|
}
|
|
|
//Take into account in-staff clefs associated with the staff entry (they modify the bounding box position)
|
|
|
- const vfClefBefore: Vex.Flow.ClefNote = (endVfVoiceEntry.parentStaffEntry as VexFlowStaffEntry).vfClefBefore;
|
|
|
+ const vfClefBefore: Vex.Flow.ClefNote = (endVfVoiceEntry?.parentStaffEntry as VexFlowStaffEntry)?.vfClefBefore;
|
|
|
if (vfClefBefore) {
|
|
|
const clefWidth: number = vfClefBefore.getWidth() / 10;
|
|
|
stopX += clefWidth;
|
|
@@ -1353,18 +1363,23 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
//Whatever is currently lower - the set render height of the begin vf stave, the set render height of the end vf stave,
|
|
|
//or the bottom line. Use that as the render height of both staves
|
|
|
footroom = Math.max(footroom, (vfPedal.startNote.getStave().options as any).bottom_text_position);
|
|
|
- if (startVfVoiceEntry.parentStaffEntry.parentMeasure !== endVfVoiceEntry.parentStaffEntry.parentMeasure) {
|
|
|
+ if (startVfVoiceEntry.parentStaffEntry.parentMeasure !== endVfVoiceEntry?.parentStaffEntry.parentMeasure && vfPedal.endNote) {
|
|
|
footroom = Math.max(footroom, (vfPedal.endNote.getStave().options as any).bottom_text_position);
|
|
|
(vfPedal.endNote.getStave().options as any).bottom_text_position = footroom;
|
|
|
}
|
|
|
(vfPedal.startNote.getStave().options as any).bottom_text_position = footroom;
|
|
|
+ if (startX > stopX) { // TODO hotfix for skybottomlinecalculator after pedal no endNote fix
|
|
|
+ const newStart: number = stopX;
|
|
|
+ stopX = startX;
|
|
|
+ startX = newStart;
|
|
|
+ }
|
|
|
parentStaffline.SkyBottomLineCalculator.updateBottomLineInRange(startX, stopX, footroom + bottomLineYOffset);
|
|
|
//This list will contain only previously processed Pedals - aka, those previous in the sheet music
|
|
|
for (const otherPedal of parentStaffline.Pedals) {
|
|
|
const vfOtherPedal: VexFlowPedal = otherPedal as VexFlowPedal;
|
|
|
//If there is a pedal that ends on our begin measure, we need to update its begin measure to render at the new height
|
|
|
//So we don't get lopsided pedal brackets
|
|
|
- if (vfOtherPedal.endVfVoiceEntry.parentStaffEntry.parentMeasure === startVfVoiceEntry.parentStaffEntry.parentMeasure) {
|
|
|
+ if (vfOtherPedal.endVfVoiceEntry?.parentStaffEntry.parentMeasure === startVfVoiceEntry.parentStaffEntry.parentMeasure) {
|
|
|
//Since we've already checked for max height for this stave above, we are certain that this pedal will not render higher than it should
|
|
|
//(e.g. colliding with stuff)
|
|
|
(vfOtherPedal.startNote.getStave().options as any).bottom_text_position = footroom;
|