Skip to content

Commit

Permalink
fix #71901: layout of cross staff seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Aug 18, 2015
1 parent 24b0bc8 commit 427f28d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
21 changes: 18 additions & 3 deletions libmscore/beam.cpp
Expand Up @@ -61,7 +61,7 @@ Beam::Beam(Score* s)
_userModified[1] = false;
_grow1 = 1.0;
_grow2 = 1.0;
editFragment = 0;
editFragment = -1;
_isGrace = false;
_cross = false;
_noSlope = score()->styleB(StyleIdx::beamNoSlope);
Expand All @@ -86,6 +86,7 @@ Beam::Beam(const Beam& b)
_userModified[1] = b._userModified[1];
_grow1 = b._grow1;
_grow2 = b._grow2;
editFragment = b.editFragment;
foreach(BeamFragment* f, b.fragments)
fragments.append(new BeamFragment(*f));
minMove = b.minMove;
Expand Down Expand Up @@ -379,8 +380,12 @@ void Beam::layout1()
// int idx = (_direction == MScore::Direction::AUTO || _direction == MScore::Direction::DOWN) ? 0 : 1;
slope = 0.0;

for (ChordRest* cr : _elements)
cr->setUp(_up);
for (ChordRest* cr : _elements) {
// leave initial guess alone for moved chords within a beam that crosses staves
// otherwise, assume beam direction is stem direction
if (!_cross || !cr->staffMove())
cr->setUp(_up);
}

} // end of if/else(tablature)
}
Expand Down Expand Up @@ -1542,6 +1547,10 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
// guess was wrong, have to relayout
if (!_isGrace) {
score()->layoutChords1(c->segment(), c->staffIdx());
// DEBUG: attempting to layout during beam edit causes crash
// probably because ledger lines are deleted and added back
if (editFragment == -1)
c->layout();
}
else {
relayoutGrace = true;
Expand Down Expand Up @@ -1586,6 +1595,11 @@ void Beam::layout2(QList<ChordRest*>crl, SpannerSegmentType, int frag)
c->setUp(nup);
// guess was wrong, have to relayout
score()->layoutChords1(c->segment(), c->staffIdx());
c->layout();
// TODO: this might affect chord space, which might affect segment position
// we should relayout entire measure
// this probably means starting over for beam as well
// see https://musescore.org/en/node/71901
}
}

Expand Down Expand Up @@ -2200,6 +2214,7 @@ void Beam::startEdit(MuseScoreView*, const QPointF& p)
void Beam::endEdit()
{
Element::endEdit();
editFragment = -1;
// we need a full relayout to trigger stems to be redrawn
score()->setLayoutAll(true);
}
Expand Down
Binary file added vtest/cross-2-ref.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/cross-2.mscz
Binary file not shown.
2 changes: 1 addition & 1 deletion vtest/gen
Expand Up @@ -41,7 +41,7 @@ else
frametext ottava slurs-1 slurs-2 slurs-3 hairpins-1 pedal-1 line-1 line-2 line-3 line-4 line-5 gliss-1 gliss-2\
chord-layout-1 chord-layout-2 chord-layout-3 chord-layout-4 chord-layout-5\
chord-layout-6 chord-layout-7 chord-layout-8 chord-layout-9 chord-layout-10\
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 chord-layout-15 chord-layout-16 cross-1\
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 chord-layout-15 chord-layout-16 cross-1 cross-2\
accidental-1 accidental-2 accidental-3 accidental-4 accidental-5\
accidental-6 accidental-7 accidental-8 accidental-9 accidental-10\
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 grace-4 tuplets-1 tuplets-2 breath-1\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Expand Up @@ -16,7 +16,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
frametext,ottava,slurs-1,slurs-2,slurs-3,hairpins-1,pedal-1,line-1,line-2,line-3,line-4,line-5,gliss-1,gliss-2, ^
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
chord-layout-6,chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,chord-layout-15,chord-layout-16,cross-1, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,chord-layout-15,chord-layout-16,cross-1,cross-2, ^
accidental-1,accidental-2,accidental-3,accidental-4,accidental-5, ^
accidental-6,accidental-7,accidental-8,accidental-9,accidental-10, ^
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,grace-4,tuplets-1,tuplets-2,breath-1, ^
Expand Down

0 comments on commit 427f28d

Please sign in to comment.