Skip to content

Commit

Permalink
Merge pull request #6224 from tobik/306821-tabstaff-and-stafflines-fo…
Browse files Browse the repository at this point in the history
…r-restcollisionavoidance

Fix #306821: TAB and number of lines in collision avoidance of rests
  • Loading branch information
anatoly-os committed Jun 20, 2020
2 parents e6a5379 + 8489bb2 commit 14aa080
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libmscore/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,21 +584,27 @@ int Rest::computeLineOffset(int lines)
int upOffset = up ? 1 : 0;
int firstTrack = staffIdx() * 4;
int line = up ? 10 : -10;
int extraOffsetForFewLines = lines < 5 ? 2 : 0;
bool isMeasureRest = durationType().type() == TDuration::DurationType::V_MEASURE;
Segment* seg = isMeasureRest ? measure()->first() : s;
while (seg) {
for (const int& track : { firstTrack + upOffset, firstTrack + 2 + upOffset }) {
Element* e = seg->element(track);
if (e && e->isChord()) {
for (Note* note : toChord(e)->notes()) {
int nline = note->line();
Chord* chord = toChord(e);
StaffGroup staffGroup = staff()->staffType(chord->tick())->group();
for (Note* note : chord->notes()) {
int nline = staffGroup == StaffGroup::TAB
? note->string() * 2
: note->line();
nline = nline - centerDiff;
if (up && nline <= line) {
line = nline;
line = nline - extraOffsetForFewLines;
if (note->accidentalType() != AccidentalType::NONE)
line--;
}
else if (!up && nline >= line) {
line = nline;
line = nline + extraOffsetForFewLines;
if (note->accidentalType() != AccidentalType::NONE)
line++;
}
Expand Down

0 comments on commit 14aa080

Please sign in to comment.