Skip to content

Commit

Permalink
fix #46006: flags in crossed voices collide with notes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Jan 30, 2015
1 parent 0dfcac4 commit 70f5820
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
qreal maxUpMag = 0.0;
qreal maxDownMag = 0.0;

// dots can affect layout of notes as well as vice versa
// dots and hooks can affect layout of notes as well as vice versa
int upDots = 0;
int downDots = 0;
bool upHooks = false;
bool downHooks = false;

for (int track = startTrack; track < endTrack; ++track) {
Element* e = segment->element(track);
Expand All @@ -138,12 +140,16 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
upStemNotes.append(chord->notes());
upDots = qMax(upDots, chord->dots());
maxUpMag = qMax(maxUpMag, chord->mag());
if (!upHooks)
upHooks = chord->hook();
}
else {
++downVoices;
downStemNotes.append(chord->notes());
downDots = qMax(downDots, chord->dots());
maxDownMag = qMax(maxDownMag, chord->mag());
if (!downHooks)
downHooks = chord->hook();
}
}
}
Expand Down Expand Up @@ -385,11 +391,16 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
upOffset = maxDownWidth + 0.3 * sp;
else if (conflictSecondUpHigher)
upOffset = maxDownWidth + 0.2 * sp;
else if ((downHooks && !upHooks) && !(upDots && !downDots))
downOffset = maxUpWidth + 0.3 * sp;
else if (conflictSecondDownHigher) {
if (downDots && !upDots)
downOffset = maxUpWidth + 0.3 * sp;
else
else {
upOffset = maxDownWidth - 0.2 * sp;
if (downHooks)
upOffset += 0.3 * sp;
}
}
else {
// no direct conflict, so parts can overlap (downstem on left)
Expand All @@ -402,6 +413,12 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
else
downDots = 0; // no need to adjust for dots in this case
upOffset = qMax(clearLeft, clearRight);
if (downHooks) {
// we will need more space to avoid collision with hook
// but we won't need as much dot adjustment
upOffset = qMax(upOffset, maxDownWidth + 0.1 * sp);
dotAdjustThreshold = maxUpWidth - 0.3 * sp;
}
// if downstem chord is small, don't center
// and we might not need as much dot adjustment either
if (centerDown > 0.0) {
Expand Down
Binary file added vtest/chord-layout-15-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/chord-layout-15.mscz
Binary file not shown.
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ else
frametext ottava slurs-1 slurs-2 slurs-3 hairpins-1 pedal-1 line-1 line-2 line-3 line-4 gliss-1 gliss-2\
chord-layout-1 chord-layout-2 chord-layout-3 chord-layout-4 chord-layout-5\
chord-layout-6 chord-layout-7 chord-layout-8 chord-layout-9 chord-layout-10\
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 cross-1\
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 chord-layout-15 cross-1\
accidental-1 accidental-2 accidental-3 accidental-4 accidental-5\
accidental-6 accidental-7 accidental-8 accidental-9\
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 grace-4\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
frametext,ottava,slurs-1,slurs-2,slurs-3,hairpins-1,pedal-1,line-1,line-2,line-3,line-4,gliss-1,gliss-2, ^
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
chord-layout-6,chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,cross-1, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,chord-layout-15,cross-1, ^
accidental-1,accidental-2,accidental-3,accidental-4,accidental-5, ^
accidental-6,accidental-7,accidental-8,accidental-9, ^
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,grace-4, ^
Expand Down

0 comments on commit 70f5820

Please sign in to comment.