Skip to content

Commit

Permalink
Merge pull request #25914 from mike-spa/fixDynamicsEndOfDurationAlign…
Browse files Browse the repository at this point in the history
…ment

Correct dynamic end-of-duration alignment in case of clefs
  • Loading branch information
cbjeukendrup authored Dec 24, 2024
2 parents a6ce77e + 7609a66 commit 4c05925
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/engraving/rendering/score/measurelayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,8 +2216,11 @@ void MeasureLayout::layoutTimeTickAnchors(Measure* m, LayoutContext& ctx)
Fraction thisDuration = segment.ticks();
Fraction relativeTick = segment.rtick() - refCRSeg->rtick();

Segment* nextCRSeg = m->findSegmentR(SegmentType::ChordRest, refCRSeg->rtick() + refCRSeg->ticks());
double width = nextCRSeg ? nextCRSeg->x() - refCRSeg->x() : refCRSeg->width();
Segment* nextSeg = m->findSegmentR(SegmentType::ChordRest, refCRSeg->rtick() + refCRSeg->ticks());
if (!nextSeg) {
nextSeg = m->findSegmentR(SegmentType::BarLineType, refCRSeg->rtick() + refCRSeg->ticks());
}
double width = nextSeg ? nextSeg->x() - refCRSeg->x() : refCRSeg->width();

double relativeX = width * (relativeTick.toDouble() / refCRSeg->ticks().toDouble());
double relativeWidth = width * (thisDuration.toDouble() / refSegDuration.toDouble());
Expand Down
9 changes: 6 additions & 3 deletions src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,11 +1950,14 @@ void TLayout::layoutDynamicToEndOfPrevious(const Dynamic* item, TextBase::Layout
{
Segment* curSegment = item->segment();
Segment* leftMostSegment = curSegment;
Segment* prevSeg = curSegment;
while (true) {
Segment* prevSeg = leftMostSegment->prev1enabled();
if (prevSeg && prevSeg->tick() == leftMostSegment->tick()) {
prevSeg = prevSeg->prev1enabled();
if (!prevSeg || prevSeg->tick() != curSegment->tick()) {
break;
}
if (prevSeg->isActive() && prevSeg->hasElements(item->staffIdx())) {
leftMostSegment = prevSeg;
} else {
break;
}
}
Expand Down
Binary file added vtest/scores/dynamics-11.mscz
Binary file not shown.

0 comments on commit 4c05925

Please sign in to comment.