Skip to content

Commit

Permalink
fix a bug with part-specific text
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidNewman committed Jan 28, 2024
1 parent d2590a8 commit c9fe94e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
2 changes: 1 addition & 1 deletion release/library/trumpet/BeethovenOp21.json

Large diffs are not rendered by default.

50 changes: 40 additions & 10 deletions release/smoosic.js
Original file line number Diff line number Diff line change
Expand Up @@ -4259,8 +4259,8 @@ function createStave(params) {
}
sig.addToStave(stave);
}
const curX = stave.getNoteStartX();
stave.setNoteStartX(curX + (params.startX - params.adjX));
// const curX = stave.getNoteStartX();
// stave.setNoteStartX(curX + (params.startX - params.adjX));
return stave;
}
function getVexTuplets(params) {
Expand Down Expand Up @@ -8601,7 +8601,7 @@ class SuiScoreRender {
// If this text is attached to the measure, base the block location on the rendered measure location.
if (newGroup.attachToSelector) {
// If this text is attached to a staff that is not visible, don't draw it.
const mappedStaff = this.score.staves.find((staff) => staff.getMappedStaffId() === newGroup.selector.staff);
const mappedStaff = this.score.staves.find((staff) => staff.staffId === newGroup.selector.staff);
if (!mappedStaff) {
return;
}
Expand Down Expand Up @@ -9550,6 +9550,12 @@ 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 @@ -9853,7 +9859,7 @@ class SuiScoreViewOperations extends _scoreView__WEBPACK_IMPORTED_MODULE_0__.Sui
}
else {
const stave = this.storeScore.staves[this._getEquivalentStaff(0)];
stave.partInfo.updateTextGroup(altGroup, false);
stave.partInfo.textGroups = this.score.textGroups;
_smo_xform_undo__WEBPACK_IMPORTED_MODULE_10__.SmoUndoable.changeTextGroup(this.storeScore, this.storeUndo, altGroup, _smo_xform_undo__WEBPACK_IMPORTED_MODULE_10__.UndoBuffer.bufferSubtypes.REMOVE);
}
this.renderer.renderScoreModifiers();
Expand Down Expand Up @@ -11375,6 +11381,8 @@ class SuiScoreViewOperations extends _scoreView__WEBPACK_IMPORTED_MODULE_0__.Sui
}
}
if (resetView || restChange || stavesChange) {
_smo_xform_operations__WEBPACK_IMPORTED_MODULE_11__.SmoOperation.computeMultipartRest(this.score);
// this.resetPartView();
this.renderer.rerenderAll();
}
return this.renderer.updatePromise();
Expand Down Expand Up @@ -25165,7 +25173,7 @@ class SmoScoreText extends _scoreModifiers__WEBPACK_IMPORTED_MODULE_1__.SmoScore
y: 15,
width: 0,
height: 0,
text: 'Smoosic',
text: 'Text',
fontInfo: {
size: 14,
family: SmoScoreText.fontFamilies.serif,
Expand Down Expand Up @@ -25231,7 +25239,7 @@ class SmoScoreText extends _scoreModifiers__WEBPACK_IMPORTED_MODULE_1__.SmoScore
this.y = 15;
this.width = 0;
this.height = 0;
this.text = 'Smoosic';
this.text = 'Text';
this.fontInfo = {
size: 14,
family: SmoScoreText.fontFamilies.serif,
Expand Down Expand Up @@ -26472,10 +26480,21 @@ class SmoSystemStaff {
isRest(index) {
return this.measures[index].isRest();
}
/**
* for the purposes of breaking up multimeasure rests, isRepeat is true if
* the next bar has a start repeat, or the current bar has an end repeat.
* @param index
* @returns
*/
isRepeat(index) {
const specialBar = !(this.measures[index].getEndBarline().barline === _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.singleBar &&
(this.measures[index].getStartBarline().barline === _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.singleBar ||
this.measures[index].getStartBarline().barline === _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.noBar));
if (index < this.measures.length - 1) {
if (this.measures[index + 1].getStartBarline().barline !== _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.singleBar &&
this.measures[index + 1].getStartBarline().barline !== _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.noBar) {
return true;
}
}
const specialBar = this.measures[index].getEndBarline().barline !== _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.singleBar &&
this.measures[index].getStartBarline().barline !== _measureModifiers__WEBPACK_IMPORTED_MODULE_3__.SmoBarline.barlines.noBar;
return specialBar || this.measures[index].repeatSymbol;
}
isRepeatSymbol(index) {
Expand Down Expand Up @@ -47789,6 +47808,7 @@ class SuiPartInfoAdapter extends _adapter__WEBPACK_IMPORTED_MODULE_5__.SuiCompon
constructor(view) {
super(view);
this.changed = false;
this.expandedMultimeasure = false;
this.currentView = [];
this.resetPart = false;
this.currentView = this.view.getView();
Expand All @@ -47803,6 +47823,13 @@ class SuiPartInfoAdapter extends _adapter__WEBPACK_IMPORTED_MODULE_5__.SuiCompon
// Since update will change the displayed score, wait for any display change to complete first.
yield this.view.renderer.updatePromise();
yield 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();
yield this.view.updatePartInfo(this.partInfo);
this.resetPart = false;
}
});
}
writeLayoutValue(attr, value) {
Expand All @@ -47825,7 +47852,10 @@ class SuiPartInfoAdapter extends _adapter__WEBPACK_IMPORTED_MODULE_5__.SuiCompon
}
set expandMultimeasureRest(value) {
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
2 changes: 1 addition & 1 deletion release/smoosic.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/common/vex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export function createStave(params: SmoVexStaveParams) {
}
sig.addToStave(stave);
}
const curX = stave.getNoteStartX();
stave.setNoteStartX(curX + (params.startX - params.adjX));
// const curX = stave.getNoteStartX();
// stave.setNoteStartX(curX + (params.startX - params.adjX));

return stave;
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/sui/scoreRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class SuiScoreRender {
// If this text is attached to the measure, base the block location on the rendered measure location.
if (newGroup.attachToSelector) {
// If this text is attached to a staff that is not visible, don't draw it.
const mappedStaff = this.score!.staves.find((staff) => staff.getMappedStaffId() === newGroup.selector!.staff);
const mappedStaff = this.score!.staves.find((staff) => staff.staffId === newGroup.selector!.staff);
if (!mappedStaff) {
return;
}
Expand Down

0 comments on commit c9fe94e

Please sign in to comment.