Skip to content

Commit

Permalink
Merge pull request #1420 from MarcSabatella/37646-system-ties
Browse files Browse the repository at this point in the history
fix 37646: bad continued tie with seconds
  • Loading branch information
wschweer committed Nov 1, 2014
2 parents d6f747f + e38e8a2 commit 49ddd5b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
23 changes: 20 additions & 3 deletions libmscore/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,15 +1434,15 @@ void Slur::layout()
// case 3: middle segment
else if (i != 0 && system != sPos.system2) {
segment->setSpannerSegmentType(SpannerSegmentType::MIDDLE);
qreal x1 = firstNoteRestSegmentX(system) - _spatium;
qreal x1 = firstNoteRestSegmentX(system);
qreal x2 = system->bbox().width();
qreal y = system->staff(staffIdx())->y();
segment->layout(QPointF(x1, y), QPointF(x2, y));
}
// case 4: end segment
else {
segment->setSpannerSegmentType(SpannerSegmentType::END);
qreal x = firstNoteRestSegmentX(system) - _spatium;
qreal x = firstNoteRestSegmentX(system);
segment->layout(QPointF(x, sPos.p2.y()), sPos.p2);
}
if (system == sPos.system2)
Expand All @@ -1454,6 +1454,7 @@ void Slur::layout()
//---------------------------------------------------------
// firstNoteRestSegmentX
// in System() coordinates
// returns the position just after the last non-chordrest segment
//---------------------------------------------------------

qreal SlurTie::firstNoteRestSegmentX(System* system)
Expand All @@ -1463,7 +1464,23 @@ qreal SlurTie::firstNoteRestSegmentX(System* system)
const Measure* measure = static_cast<const Measure*>(mb);
for (const Segment* seg = measure->first(); seg; seg = seg->next()) {
if (seg->segmentType() == Segment::Type::ChordRest) {
return seg->pos().x() + seg->measure()->pos().x();
// first CR found; back up to previous segment
seg = seg->prev();
if (seg) {
// find maximum width
qreal width = 0.0;
int n = score()->nstaves();
for (int i = 0; i < n; ++i) {
if (!system->staff(i)->show())
continue;
Element* e = seg->element(i * VOICES);
if (e)
width = qMax(width, e->width());
}
return seg->measure()->pos().x() + seg->pos().x() + width;
}
else
return 0.0;
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions libmscore/tie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,6 @@ void Tie::calculateDirection()

void Tie::layout()
{
qreal _spatium = spatium();

//
// show short bow
//
Expand Down Expand Up @@ -405,7 +403,7 @@ void Tie::layout()
}
// case 4: end segment
else {
qreal x = firstNoteRestSegmentX(system) - 2 * _spatium;
qreal x = firstNoteRestSegmentX(system);

segment->layout(QPointF(x, sPos.p2.y()), sPos.p2);
segment->setSpannerSegmentType(SpannerSegmentType::END);
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ else
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 cross-1\
accidental-1 accidental-2 accidental-3 accidental-4 accidental-5\
accidental-6 accidental-7 accidental-8 accidental-9\
tie-1 tie-2 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 harmony-4 beams-1 beams-2\
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 harmony-4 beams-1 beams-2\
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1\
lyrics-1 lyrics-2 lyrics-3 voice-1"
fi
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,cross-1, ^
accidental-1,accidental-2,accidental-3,accidental-4,accidental-5, ^
accidental-6,accidental-7,accidental-8,accidental-9, ^
tie-1,tie-2,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,harmony-4,beams-1,beams-2, ^
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,harmony-4,beams-1,beams-2, ^
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1, ^
lyrics-1,lyrics-2,lyrics-3,voice-1

Expand Down
Binary file added vtest/tie-3-ref.png
Loading
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/tie-3.mscz
Binary file not shown.

0 comments on commit 49ddd5b

Please sign in to comment.