Skip to content

Commit

Permalink
Merge pull request musescore#26365 from mike-spa/fixDynamicCenteringBug
Browse files Browse the repository at this point in the history
Fix wrong interaction between hairpins and dynamics when centering
  • Loading branch information
mike-spa authored Feb 10, 2025
2 parents 42bdfb2 + 441c37a commit 9af8b2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/engraving/rendering/score/autoplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,22 @@ void Autoplace::doAutoplace(const Articulation* item, Articulation::LayoutData*

bool Autoplace::itemsShouldIgnoreEachOther(const EngravingItem* itemToAutoplace, const EngravingItem* itemInSkyline)
{
if (itemInSkyline->isText() && itemInSkyline->explicitParent() && itemInSkyline->parent()->isSLineSegment()) {
return itemsShouldIgnoreEachOther(itemToAutoplace, itemInSkyline->parentItem());
}

ElementType type1 = itemToAutoplace->type();
ElementType type2 = itemInSkyline->type();

if (type1 == ElementType::TIMESIG) {
return type2 != ElementType::KEYSIG;
}

if ((type1 == ElementType::DYNAMIC || type1 == ElementType::HAIRPIN_SEGMENT)
&& (type2 == ElementType::DYNAMIC || type2 == ElementType::HAIRPIN_SEGMENT)) {
return true;
}

if (type1 == type2) {
// Items of same type should ignore each other in most cases
static const std::set<ElementType> TEXT_BASED_TYPES_WHICH_IGNORE_EACH_OTHER {
Expand Down
4 changes: 1 addition & 3 deletions src/engraving/rendering/score/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2946,9 +2946,7 @@ void SystemLayout::centerElementBetweenStaves(EngravingItem* element, const Syst
if (!shapeItem) {
return false;
}
return shapeItem == element || shapeItem->parentItem(true) == element || shapeItem->type() == element->type()
|| shapeItem->isAccidental() || shapeItem == element->ldata()->itemSnappedBefore()
|| shapeItem == element->ldata()->itemSnappedAfter();
return shapeItem->isAccidental() || Autoplace::itemsShouldIgnoreEachOther(element, shapeItem);
});

double yStaffDiff = nextStaff->y() - thisStaff->y();
Expand Down
Binary file added vtest/scores/hairpins-3.mscz
Binary file not shown.

0 comments on commit 9af8b2d

Please sign in to comment.