Skip to content

Commit

Permalink
Fix GH#19669: Enable 2nd adjustment for cross staff beamed notes
Browse files Browse the repository at this point in the history
Backport of musescore#19831
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Oct 26, 2023
1 parent 02224ef commit e8e7c53
Show file tree
Hide file tree
Showing 4 changed files with 740 additions and 14 deletions.
16 changes: 4 additions & 12 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
return;
}

bool crossBeamFound = false;
std::vector<Note*> upStemNotes;
std::vector<Note*> downStemNotes;
int upVoices = 0;
Expand All @@ -182,8 +181,6 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
Element* e = segment->element(track);
if (e && e->isChord()) {
Chord* chord = toChord(e);
if (chord->beam() && chord->beam()->cross())
crossBeamFound = true;
bool hasGraceBefore = false;
for (Chord* c : chord->graceNotes()) {
if (c->isGraceBefore())
Expand All @@ -196,7 +193,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
upStemNotes.insert(upStemNotes.end(), chord->notes().begin(), chord->notes().end());
upDots = qMax(upDots, chord->dots());
maxUpMag = qMax(maxUpMag, chord->mag());
if (!upHooks)
if (!upHooks && !chord->beam())
upHooks = chord->hook();
if (hasGraceBefore)
upGrace = true;
Expand All @@ -206,7 +203,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
downStemNotes.insert(downStemNotes.end(), chord->notes().begin(), chord->notes().end());
downDots = qMax(downDots, chord->dots());
maxDownMag = qMax(maxDownMag, chord->mag());
if (!downHooks)
if (!downHooks && !chord->beam())
downHooks = chord->hook();
if (hasGraceBefore)
downGrace = true;
Expand Down Expand Up @@ -314,13 +311,8 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
if (upVoices && downVoices) {
Note* bottomUpNote = upStemNotes.front();
Note* topDownNote = downStemNotes.back();
int separation;
// TODO: handle conflicts for cross-staff notes and notes on cross-staff beams
// for now we simply treat these as though there is no conflict
if (bottomUpNote->chord()->staffMove() == topDownNote->chord()->staffMove() && !crossBeamFound)
separation = topDownNote->line() - bottomUpNote->line();
else
separation = 2; // no conflict
int separation = topDownNote->line() - bottomUpNote->line();

QVector<Note*> overlapNotes;
overlapNotes.reserve(8);

Expand Down
Loading

0 comments on commit e8e7c53

Please sign in to comment.