Skip to content

Commit

Permalink
Merge pull request #26457 from mike-spa/alignAccidentalsToRightSide
Browse files Browse the repository at this point in the history
Alignment corrections with accidentals of different sizes
  • Loading branch information
miiizen authored Feb 18, 2025
2 parents 12ba012 + d734506 commit 988016f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/engraving/rendering/score/accidentalslayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@ void AccidentalsLayout::collectVerticalSets(
double x1 = xPosRelativeToSegment(acc1);
for (size_t j = i + 1; j < ctx.allAccidentals.size(); ++j) {
Accidental* acc2 = ctx.allAccidentals[j];
if (acc2->accidentalType() != acc1->accidentalType() || muse::contains(accidentalsAlreadyGrouped, acc2)) {
if (acc2->accidentalType() != acc1->accidentalType() || muse::contains(accidentalsAlreadyGrouped, acc2)
|| !muse::RealIsEqual(acc1->mag(), acc2->mag())) {
continue;
}
int column2 = acc2->ldata()->column;
Expand All @@ -1057,10 +1058,12 @@ void AccidentalsLayout::alignVerticalSets(AccidentalGroups& vertSets, Accidental
// Align the set
double x = DBL_MAX;
for (Accidental* acc : vertSet) {
x = std::min(x, xPosRelativeToSegment(acc));
double rightEdge = acc->ldata()->bbox().right() + xPosRelativeToSegment(acc);
x = std::min(x, rightEdge);
}
for (Accidental* acc : vertSet) {
setXposRelativeToSegment(acc, x);
double bboxRight = acc->ldata()->bbox().right();
setXposRelativeToSegment(acc, x - bboxRight);
}

// Re-check the outer ones for collisions
Expand Down
Binary file added vtest/scores/accidental-38.mscz
Binary file not shown.
Binary file added vtest/scores/accidental-39.mscz
Binary file not shown.

0 comments on commit 988016f

Please sign in to comment.