Skip to content

Commit

Permalink
fix #29151: tie positioning in chords
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Aug 9, 2014
1 parent 5a616ff commit eb653d7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,23 @@ void SlurSegment::layout(const QPointF& p1, const QPointF& p2)
QRectF bbox = path.boundingRect();

// adjust position to avoid staff line if necessary
bool reverseAdjust = false;
if (slurTie()->type() == Element::Type::TIE) {
// multinote chords with ties need special handling
// otherwise, adjusted tie might crowd an unadjusted tie unnecessarily
Tie* t = static_cast<Tie*>(slurTie());
Note* sn = t->startNote();
Chord* sc = sn ? sn->chord() : 0;
// normally, the adjustment moves ties according to their direction (eg, up if tie is up)
// but we will reverse this for notes within chords when appropriate
// for two-note chords, it looks better to have ties on notes with spaces outside the lines
if (sc) {
int notes = sc->notes().size();
bool onLine = !(sn->line() & 1);
if ((onLine && notes > 1) || (!onLine && notes > 2))
reverseAdjust = true;
}
}
qreal sp = spatium();
qreal minDistance = 0.5;
Staff* st = staff();
Expand All @@ -601,7 +618,7 @@ void SlurSegment::layout(const QPointF& p1, const QPointF& p2)
if (!isNudged() && !isEdited()) {
// user has not nudged or edited
qreal offY;
if (up)
if (up != reverseAdjust) // exclusive or
offY = (lineY - minDistance) - topY;
else
offY = (lineY + minDistance) - bottomY;
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
chord-layout-11 chord-layout-12 chord-layout-13\
accidental-1 accidental-2 accidental-3 accidental-4\
accidental-5 accidental-6 accidental-7 accidental-8\
tie-1 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 beams-1 beams-2\
tie-1 tie-2 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 beams-1 beams-2\
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1"
fi

Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set SRC=mmrest-1,bravura-mmrest,mmrest-2,mmrest-4,mmrest-5,mmrest-6,mmrest-7,mmr
chord-layout-11,chord-layout-12,chord-layout-13, ^
accidental-1,accidental-2,accidental-3,accidental-4, ^
accidental-5,accidental-6,accidental-7,accidental-8, ^
tie-1,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,beams-1,beams-2, ^
tie-1,tie-2,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,beams-1,beams-2, ^
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1

set MSCORE=..\win32install\bin\mscore.exe
Expand Down
Binary file added vtest/tie-2-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/tie-2.mscz
Binary file not shown.

0 comments on commit eb653d7

Please sign in to comment.