Skip to content

Commit

Permalink
fix generated width in toVex, fix a bug in SystemGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidNewman committed Feb 1, 2024
1 parent 24f1589 commit 398886d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/render/vex/toVex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ function createColumn(groups: Record<string, VexStaveGroupMusic>, strs: string[]
const joinVoiceStr = '[' + music.voiceStrings.join(',') + ']';
const widthMeasure = music.measures[0];
const staffWidth = Math.round(widthMeasure.staffWidth -
(widthMeasure.svg.adjX + widthMeasure.svg.adjRight + widthMeasure.format.padLeft) - 10);
(widthMeasure.svg.maxColumnStartX + widthMeasure.svg.adjRight + widthMeasure.format.padLeft) - 10);
strs.push(`${music.formatter}.format(${joinVoiceStr}, ${staffWidth});`);
music.measures.forEach((smoMeasure) => {
createMeasure(smoMeasure, music.heightOffset, strs);
Expand Down
17 changes: 16 additions & 1 deletion src/smo/data/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export class SmoScore {
}
this.audioSettings = new SmoAudioPlayerSettings(params.audioSettings);
this.updateMeasureFormats();
this.updateSystemGroups();
}
static get engravingFonts(): Record<string, string> {
return { Bravura: 'Bravura', Gonville: 'Gonville', Petaluma: 'Petaluma' };
Expand Down Expand Up @@ -1092,7 +1093,20 @@ export class SmoScore {
this.numberStaves();
return staff;
}

/**
* delete any system groups that apply to deleted staves
*/
updateSystemGroups() {
const grpToKeep: SmoSystemGroup[] = [];
this.systemGroups.forEach((grp) => {
if (grp.startSelector.staff < this.staves.length &&
grp.endSelector.staff < this.staves.length
) {
grpToKeep.push(grp);
}
});
this.systemGroups = grpToKeep;
}
// ### removeStaff
// Remove stave at the given index
removeStaff(index: number) {
Expand All @@ -1106,6 +1120,7 @@ export class SmoScore {
});
this.staves = staves;
this.numberStaves();
this.updateSystemGroups();
}
getStaffInstrument(selector: SmoSelector): SmoInstrument {
const staff: SmoSystemStaff = this.staves[selector.staff];
Expand Down

0 comments on commit 398886d

Please sign in to comment.