Skip to content

Commit

Permalink
Merge pull request #5987 from Howard-C/tremolo-layout-fix
Browse files Browse the repository at this point in the history
Fix layout of tremolos attached to chords with opposite stem directions
  • Loading branch information
anatoly-os authored Apr 26, 2020
2 parents 3de239f + dabfae0 commit 97720a2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions libmscore/tremolo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ void Tremolo::layoutTwoNotesTremolo(qreal x, qreal y, qreal h, qreal _spatium)
// TODO const qreal MAX_H_LENGTH = _spatium * score()->styleS(Sid::tremoloBeamLengthMultiplier).val();
const qreal MAX_H_LENGTH = _spatium * 12.0;

qreal xScaleFactor = defaultStyle ? qMin(H_MULTIPLIER * (x2 - x1), MAX_H_LENGTH) : H_MULTIPLIER * (x2 - x1);
qreal defaultLength = qMin(H_MULTIPLIER * (x2 - x1), MAX_H_LENGTH);
qreal xScaleFactor = defaultStyle ? defaultLength : H_MULTIPLIER * (x2 - x1);
const qreal w2 = _spatium * score()->styleS(Sid::tremoloWidth).val() * .5;
xScaleFactor /= (2.0 * w2);

Expand All @@ -483,14 +484,6 @@ void Tremolo::layoutTwoNotesTremolo(qreal x, qreal y, qreal h, qreal _spatium)
}
QTransform shearTransform;
qreal dy = y2 - y1;
// Make tremolo strokes less deep if two chords have the opposite stem direction,
// except for two cases:
// 1. The tremolo doesn't have the default beam style.
// In this case tremolo strokes should attach to the ends of both stems, so no adjustment needed;
// 2. The chords are on different staves and the tremolo is between them.
// The layout should be improved by extending both stems, so changes are not needed here.
if (_chord1->up() != _chord2->up() && defaultStyle && !crossStaffBeamBetween())
dy = qMin(qMax(dy, -1.0 * _spatium), 1.0 * _spatium);
qreal dx = x2 - x1;
if (_chord1->beams() == 0 && _chord2->beams() == 0) {
if (_chord1->up() && !_chord2->up()) {
Expand All @@ -504,6 +497,14 @@ void Tremolo::layoutTwoNotesTremolo(qreal x, qreal y, qreal h, qreal _spatium)
dy -= lw;
}
}
// Make tremolo strokes less steep if two chords have the opposite stem directions,
// except for two cases:
// 1. The tremolo doesn't have the default beam style.
// In this case tremolo strokes should attach to the ends of both stems, so no adjustment needed;
// 2. The chords are on different staves and the tremolo is between them.
// The layout should be improved by extending both stems, so changes are not needed here.
if (_chord1->up() != _chord2->up() && defaultStyle && !crossStaffBeamBetween())
dy = qMin(qMax(dy, -1.0 * _spatium / defaultLength * dx), 1.0 * _spatium / defaultLength * dx);
qreal ds = dy / dx;
shearTransform.shear(0.0, ds);
path = shearTransform.map(path);
Expand Down

0 comments on commit 97720a2

Please sign in to comment.