Skip to content
Permalink
Browse files

Merge pull request #4342 from pthvogt/278153-voltas

278153 voltas
  • Loading branch information...
anatoly-os committed Dec 12, 2018
2 parents 6b0ec14 + e3d1051 commit e5d17fc3068c995b153beb0dea8b099457be7639
Showing with 78 additions and 44 deletions.
  1. +42 −27 libmscore/layout.cpp
  2. +36 −17 libmscore/layoutlinear.cpp
  3. BIN mtest/libmscore/midi/testVoltaTemp-ref.mid
@@ -3438,14 +3438,55 @@ void Score::layoutSystemElements(System* system, LayoutContext& lc)
ottavas.push_back(sp);
else if (sp->isPedal())
pedal.push_back(sp);
else if (!sp->isSlur()) // slurs are already handled
else if (!sp->isSlur() && !sp->isVolta()) // slurs are already, voltas will be later handled
spanner.push_back(sp);
}
}
processLines(system, ottavas, false);
processLines(system, pedal, true);
processLines(system, spanner, false);

//-------------------------------------------------------------
// TempoText, Fermata, TremoloBar
//-------------------------------------------------------------

for (const Segment* s : sl) {
for (Element* e : s->annotations()) {
if (e->isTempoText()) {
TempoText* tt = toTempoText(e);
if (score()->isMaster())
setTempo(tt->segment(), tt->tempo());
tt->layout();
}
else if (e->isFermata() || e->isTremoloBar())
e->layout();
}
}

layoutLyrics(system);

// here are lyrics dashes and melisma
for (Spanner* sp : _unmanagedSpanner) {
if (sp->tick() >= etick || sp->tick2() <= stick)
continue;
sp->layoutSystem(system);
}

//-------------------------------------------------------------
// layout Voltas for current sytem
//-------------------------------------------------------------

std::vector<Spanner*> voltas;

for (auto interval : spanners) {
Spanner* sp = interval.value;
if (sp->tick() < etick && sp->tick2() > stick) {
if (sp->isVolta())
voltas.push_back(sp);
}
}
processLines(system, voltas, false);

//
// vertical align volta segments
//
@@ -3477,32 +3518,6 @@ void Score::layoutSystemElements(System* system, LayoutContext& lc)
}
}

//-------------------------------------------------------------
// TempoText, Fermata, TremoloBar
//-------------------------------------------------------------

for (const Segment* s : sl) {
for (Element* e : s->annotations()) {
if (e->isTempoText()) {
TempoText* tt = toTempoText(e);
if (score()->isMaster())
setTempo(tt->segment(), tt->tempo());
tt->layout();
}
else if (e->isFermata() || e->isTremoloBar())
e->layout();
}
}

layoutLyrics(system);

// here are lyrics dashes and melisma
for (Spanner* sp : _unmanagedSpanner) {
if (sp->tick() >= etick || sp->tick2() <= stick)
continue;
sp->layoutSystem(system);
}

//-------------------------------------------------------------
// Jump, Marker
//-------------------------------------------------------------
@@ -313,29 +313,13 @@ void LayoutContext::layoutLinear()
ottavas.push_back(sp);
else if (sp->isPedal())
pedal.push_back(sp);
else if (!sp->isSlur()) // slurs are already handled
else if (!sp->isSlur() && !sp->isVolta()) // slurs are already, voltas will be later handled
spanner.push_back(sp);
}
}
processLines(system, ottavas, false);
processLines(system, pedal, true);
processLines(system, spanner, false);

//
// vertical align volta segments
//
std::vector<SpannerSegment*> voltaSegments;
for (SpannerSegment* ss : system->spannerSegments()) {
if (ss->isVoltaSegment())
voltaSegments.push_back(ss);
}
if (voltaSegments.size() > 1) {
qreal y = 0;
for (SpannerSegment* ss : voltaSegments)
y = qMin(y, ss->offset().y());
for (SpannerSegment* ss : voltaSegments)
ss->ryoffset() = y;
}
}

//
@@ -361,6 +345,41 @@ void LayoutContext::layoutLinear()
}
}

//
// Volta
//

if (etick > stick) { // ignore vbox
auto spanners = score->spannerMap().findOverlapping(stick, etick);

std::vector<Spanner*> voltas;

for (auto interval : spanners) {
Spanner* sp = interval.value;
if (sp->tick() < etick && sp->tick2() > stick) {
if (sp->isVolta())
voltas.push_back(sp);
}
}
processLines(system, voltas, false);

//
// vertical align volta segments
//
std::vector<SpannerSegment*> voltaSegments;
for (SpannerSegment* ss : system->spannerSegments()) {
if (ss->isVoltaSegment())
voltaSegments.push_back(ss);
}
if (voltaSegments.size() > 1) {
qreal y = 0;
for (SpannerSegment* ss : voltaSegments)
y = qMin(y, ss->offset().y());
for (SpannerSegment* ss : voltaSegments)
ss->ryoffset() = y;
}
}

//
// Jump, Marker
//
Binary file not shown.

0 comments on commit e5d17fc

Please sign in to comment.
You can’t perform that action at this time.