Skip to content

Commit

Permalink
fix issues with parts and text groups
Browse files Browse the repository at this point in the history
allow parts to change expanded rests without reloading the part
  • Loading branch information
AaronDavidNewman committed Jan 21, 2024
1 parent 43388c5 commit 898aef3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/render/sui/scoreView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ export abstract class SuiScoreView {
staff.setMappedStaffId(this.staffMap[staff.staffId]);
});
}
resetPartView() {
if (this.staffMap.length === 1) {
const staff = this.storeScore.staves[this.staffMap[0]];
this.exposePart(staff);
}
}
/**
* Exposes a part: hides non-part staves, shows part staves.
* Note this will reset the view. After this operation, staff 0 will
Expand Down Expand Up @@ -492,7 +498,6 @@ export abstract class SuiScoreView {
}
});
}

/**
* Update the list of staves in the score that are displayed.
*/
Expand Down
7 changes: 4 additions & 3 deletions src/render/sui/scoreViewOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ export class SuiScoreViewOperations extends SuiScoreView {
this.storeScore.updateTextGroup(altGroup, false);
} else {
const stave = this.storeScore.staves[this._getEquivalentStaff(0)];
stave.partInfo.updateTextGroup(altGroup, false);
stave.partInfo.textGroups = this.score.textGroups;
SmoUndoable.changeTextGroup(this.storeScore, this.storeUndo, altGroup,
UndoBuffer.bufferSubtypes.REMOVE);

UndoBuffer.bufferSubtypes.REMOVE);
}
this.renderer.renderScoreModifiers();
return this.renderer.updatePromise()
Expand Down Expand Up @@ -1608,6 +1607,8 @@ export class SuiScoreViewOperations extends SuiScoreView {
}
}
if (resetView || restChange || stavesChange) {
SmoOperation.computeMultipartRest(this.score);
// this.resetPartView();
this.renderer.rerenderAll()
}
return this.renderer.updatePromise();
Expand Down
4 changes: 2 additions & 2 deletions src/smo/data/scoreText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class SmoScoreText extends SmoScoreModifierBase {
y: 15,
width: 0,
height: 0,
text: 'Smoosic',
text: 'Text',
fontInfo: {
size: 14,
family: SmoScoreText.fontFamilies.serif,
Expand All @@ -153,7 +153,7 @@ export class SmoScoreText extends SmoScoreModifierBase {
y: number = 15;
width: number = 0;
height: number = 0;
text: string = 'Smoosic';
text: string = 'Text';
fontInfo: FontInfo = {
size: 14,
family: SmoScoreText.fontFamilies.serif,
Expand Down
15 changes: 13 additions & 2 deletions src/ui/dialogs/partInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class SuiPartInfoAdapter extends SuiComponentAdapter {
backup: SmoPartInfo;
selection: SmoSelection;
changed: boolean = false;
expandedMultimeasure: boolean = false;
currentView: ViewMapEntry[] = [];
resetPart: boolean = false;
constructor(view: SuiScoreViewOperations) {
Expand All @@ -29,10 +30,17 @@ export class SuiPartInfoAdapter extends SuiComponentAdapter {
this.backup = new SmoPartInfo(this.selection.staff.partInfo);
}
async update() {
this.changed = true;
this.changed = true;
// Since update will change the displayed score, wait for any display change to complete first.
await this.view.renderer.updatePromise();
await this.view.updatePartInfo(this.partInfo);
// If we are expanding rests, we need to reload the part after setting the
// part change. So we update the part display a second time with the new value.
if (this.resetPart) {
this.view.resetPartView();
await this.view.updatePartInfo(this.partInfo);
this.resetPart = false;
}
}
writeLayoutValue(attr: GlobalLayoutAttributes, value: number) {
// no change?
Expand All @@ -54,7 +62,10 @@ export class SuiPartInfoAdapter extends SuiComponentAdapter {
}
set expandMultimeasureRest(value: boolean) {
this.partInfo.expandMultimeasureRests = value;
this.resetPart = true;
// If expanding rests, we need to re-read the score, so end
if (value === true) {
this.resetPart = true;
}
this.update();
}
get noteSpacing() {
Expand Down

0 comments on commit 898aef3

Please sign in to comment.