Skip to content

Commit

Permalink
some fixes for #18943
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Oct 27, 2014
1 parent a92d346 commit f262e9c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions libmscore/beam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ void Beam::layout1()
_up = _direction == MScore::Direction::UP;
}
else {
if (c1) {
if (maxMove > 0) // cross staff beaming down
_up = false;
else if (c1) {
Measure* m = c1->measure();
if (c1->stemDirection() != MScore::Direction::AUTO)
_up = c1->stemDirection() == MScore::Direction::UP;
Expand All @@ -350,6 +352,7 @@ void Beam::layout1()
_up = true;
}


cross = minMove < maxMove;
// int idx = (_direction == MScore::Direction::AUTO || _direction == MScore::Direction::DOWN) ? 0 : 1;
slope = 0.0;
Expand Down Expand Up @@ -1404,10 +1407,8 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
const ChordRest* c2 = crl.back(); // last chord/rest in beam

int beamLevels = 1;
foreach(ChordRest* c, crl) {
int bl = c->durationType().hooks();
beamLevels = qMax(beamLevels, bl);
}
for (const ChordRest* c : crl)
beamLevels = qMax(beamLevels, c->durationType().hooks());

BeamFragment* f = fragments[frag];
int dIdx = (_direction == MScore::Direction::AUTO || _direction == MScore::Direction::DOWN) ? 0 : 1;
Expand Down Expand Up @@ -1502,8 +1503,8 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
//
// set stem direction for every chord
//
for (int i = 0; i < n; ++i) {
Chord* c = static_cast<Chord*>(crl.at(i));
for (ChordRest* cr : crl) {
Chord* c = static_cast<Chord*>(cr);
if (c->type() != Element::Type::CHORD)
continue;
qreal y = c->upNote()->pagePos().y();
Expand All @@ -1512,14 +1513,16 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
c->setUp(nup);
// guess was wrong, have to relayout
score()->layoutChords1(c->segment(), c->staffIdx());
if (c->stem())
c->stem()->rypos() = (c->up() ? c->downNote() : c->upNote())->rypos();
}
}

qreal yDownMax = -300000;
qreal yUpMin = 300000;

for (int i = 0; i < n; ++i) {
Chord* c = static_cast<Chord*>(crl.at(i));
for (ChordRest* cr : crl) {
Chord* c = static_cast<Chord*>(cr);
if (c->type() != Element::Type::CHORD)
continue;
bool _up = c->up();
Expand Down Expand Up @@ -1691,10 +1694,10 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
}

//
// create stems
// calculate stem length
//
for (int i = 0; i < n; ++i) {
Chord* c = static_cast<Chord*>(crl[i]);
for (ChordRest* cr : crl) {
Chord* c = static_cast<Chord*>(cr);
if (c->type() != Element::Type::CHORD)
continue;
Stem* stem = c->stem();
Expand All @@ -1703,6 +1706,7 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
qDebug("create stem in layout beam");
stem = new Stem(score());
c->setStem(stem);
stem->rypos() = (c->up() ? c->downNote() : c->upNote())->rypos();
}
if (c->hook())
score()->undoRemoveElement(c->hook());
Expand Down Expand Up @@ -1750,7 +1754,7 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
//
// layout stem slash for acciacatura
//
if ((i == 0) && c->noteType() == NoteType::ACCIACCATURA) {
if ((c == crl.front()) && c->noteType() == NoteType::ACCIACCATURA) {
StemSlash* stemSlash = c->stemSlash();
if (!stemSlash) {
stemSlash = new StemSlash(score());
Expand Down

0 comments on commit f262e9c

Please sign in to comment.