Skip to content

Commit

Permalink
Merge pull request #4260 from dmitrio95/122561-tab-rests
Browse files Browse the repository at this point in the history
fix #122561: layout rests in tablatures
  • Loading branch information
anatoly-os authored Dec 3, 2018
2 parents 79d5bed + 3353e5e commit 960fcfc
Show file tree
Hide file tree
Showing 4 changed files with 996 additions and 13 deletions.
26 changes: 18 additions & 8 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ void Score::rebuildBspTree()
page->rebuildBspTree();
}

//---------------------------------------------------------
// layoutSegmentElements
//---------------------------------------------------------

static void layoutSegmentElements(Segment* segment, int startTrack, int endTrack)
{
for (int track = startTrack; track < endTrack; ++track) {
if (Element* e = segment->element(track))
e->layout();
}
}

//---------------------------------------------------------
// layoutChords1
// - layout upstem and downstem chords
Expand All @@ -92,16 +104,18 @@ void Score::rebuildBspTree()
void Score::layoutChords1(Segment* segment, int staffIdx)
{
const Staff* staff = Score::staff(staffIdx);
const int startTrack = staffIdx * VOICES;
const int endTrack = startTrack + VOICES;

if (staff->isTabStaff(segment->tick()))
if (staff->isTabStaff(segment->tick())) {
layoutSegmentElements(segment, startTrack, endTrack);
return;
}

std::vector<Note*> upStemNotes;
std::vector<Note*> downStemNotes;
int upVoices = 0;
int downVoices = 0;
int startTrack = staffIdx * VOICES;
int endTrack = startTrack + VOICES;
qreal nominalWidth = noteHeadWidth() * staff->mag(segment->tick());
qreal maxUpWidth = 0.0;
qreal maxDownWidth = 0.0;
Expand Down Expand Up @@ -510,11 +524,7 @@ void Score::layoutChords1(Segment* segment, int staffIdx)
layoutChords3(notes, staff, segment);
}

for (int track = startTrack; track < endTrack; ++track) {
Element* e = segment->element(track);
if (e)
e->layout();
}
layoutSegmentElements(segment, startTrack, endTrack);
}

//---------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion mtest/libmscore/layout_elements/layout_elements.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,14 @@
</Chord>
<FiguredBass>
<ticks>480</ticks>
<text>Figured_bass</text>
<FiguredBassItem>
<brackets b0="0" b1="0" b2="0" b3="0" b4="0"/>
<digit>5</digit>
</FiguredBassItem>
<FiguredBassItem>
<brackets b0="0" b1="0" b2="0" b3="0" b4="0"/>
<digit>3</digit>
</FiguredBassItem>
</FiguredBass>
<Chord>
<durationType>quarter</durationType>
Expand Down
Loading

0 comments on commit 960fcfc

Please sign in to comment.