Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #46736: spanner end cannot be set to note in voice > 1 #1753

Merged
merged 2 commits into from Feb 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 23 additions & 20 deletions libmscore/line.cpp
Expand Up @@ -201,6 +201,7 @@ bool LineSegment::edit(MuseScoreView* sv, Grip curGrip, int key, Qt::KeyboardMod
SLine* l = line();
SpannerSegmentType st = spannerSegmentType();
int track = l->track();
int track2 = l->track2(); // assumed to be same as track

if (l->anchor() == Spanner::Anchor::SEGMENT) {
Segment* s1 = spanner()->startSegment();
Expand All @@ -220,13 +221,13 @@ bool LineSegment::edit(MuseScoreView* sv, Grip curGrip, int key, Qt::KeyboardMod
if (curGrip == Grip::START)
s1 = prevSeg1(s1, track);
else if (curGrip == Grip::END || curGrip == Grip::MIDDLE)
s2 = prevSeg1(s2, track);
s2 = prevSeg1(s2, track2);
}
else if (key == Qt::Key_Right) {
if (curGrip == Grip::START)
s1 = nextSeg1(s1, track);
else if (curGrip == Grip::END || curGrip == Grip::MIDDLE) {
Segment* ns2 = nextSeg1(s2, track);
Segment* ns2 = nextSeg1(s2, track2);
if (ns2)
s2 = ns2;
else
Expand Down Expand Up @@ -541,30 +542,32 @@ QPointF SLine::linePos(Grip grip, System** sys) const
else if (type() == Element::Type::HAIRPIN || type() == Element::Type::TRILL
|| type() == Element::Type::TEXTLINE || type() == Element::Type::LYRICSLINE) {
// (for LYRICSLINE, this is hyphen; melisma line is handled above)
// lay out to just before next CR or barline
// lay out to just before next chordrest on this staff, or barline
// tick2 actually tells us the right chordrest to look for
if (cr && endElement()->parent() && endElement()->parent()->type() == Element::Type::SEGMENT) {
qreal x2 = cr->x() + cr->space().rw();
int t = track2();
Segment* seg = static_cast<Segment*>(endElement()->parent())->next();
for ( ; seg; seg = seg->next()) {
if (seg->segmentType() == Segment::Type::ChordRest) {
if (t != -1 && !seg->element(t)) {
continue;
}
x2 = qMax(x2, seg->x() - sp);
break;
}
else if (seg->segmentType() == Segment::Type::EndBarLine) {
// allow lyrics hyphen to extend to barline; other lines stop 1sp short
qreal gap = (type() == Element::Type::LYRICSLINE) ? 0.0 : sp;
x2 = qMax(x2, seg->x() - gap);
break;
}
}
Segment* currentSeg = static_cast<Segment*>(endElement()->parent());
Segment* seg = score()->tick2segmentMM(tick2(), false, Segment::Type::ChordRest);
if (!seg) {
// no end segment found, use measure width
x2 = endElement()->parent()->parent()->width() - sp;
}
else if (currentSeg->measure() == seg->measure()) {
// next chordrest found in same measure;
// end line 1sp to left
x2 = qMax(x2, seg->x() - sp);
}
else {
// next chordrest is in next measure
// lay out to end (barline) of current measure instead
seg = currentSeg->next(Segment::Type::EndBarLine);
if (!seg)
seg = currentSeg->measure()->last();
// allow lyrics hyphen to extend to barline
// other lines stop 1sp short
qreal gap = (type() == Element::Type::LYRICSLINE) ? 0.0 : sp;
x2 = qMax(x2, seg->x() - gap);
}
x = x2 - endElement()->parent()->x();
}
}
Expand Down
8 changes: 6 additions & 2 deletions libmscore/score.cpp
Expand Up @@ -3582,6 +3582,7 @@ ChordRest* Score::findCR(int tick, int track) const
//---------------------------------------------------------
// findCRinStaff
// find chord/rest <= tick in staff
// prefer shortest duration (so it does not overlap next chordrest segment)
//---------------------------------------------------------

ChordRest* Score::findCRinStaff(int tick, int track) const
Expand All @@ -3602,11 +3603,14 @@ ChordRest* Score::findCRinStaff(int tick, int track) const
for (Segment* ns = s; ; ns = ns->next(Segment::Type::ChordRest)) {
if (ns == 0 || ns->tick() > tick)
break;
// found a segment; now find shortest chordrest on this staff (if any)
ChordRest* shortestCR = 0;
for (int t = strack; t < etrack; ++t) {
if (ns->element(t)) {
ChordRest* cr = static_cast<ChordRest*>(ns->element(t));
if (cr && (!shortestCR || cr->actualTicks() < shortestCR->actualTicks())) {
shortestCR = cr;
s = ns;
actualTrack = t;
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions libmscore/spanner.cpp
Expand Up @@ -456,6 +456,10 @@ void Spanner::computeEndElement()
switch (_anchor) {
case Anchor::SEGMENT: {
_endElement = score()->findCRinStaff(tick2() - 1, track2());
if (!_endElement) {
qDebug("%s no end element for tick %d", name(), tick2());
return;
}
int nticks = endCR()->tick() + endCR()->actualTicks() - _tick;
if (_ticks != nticks) {
qDebug("%s ticks changed, %d -> %d", name(), _ticks, nticks);
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Expand Up @@ -38,7 +38,7 @@ else
emmentaler-text-1 gonville-text-1 bravura-text-1 musejazz-text-1\
emmentaler-text-2 gonville-text-2 bravura-text-2 musejazz-text-2\
emmentaler-text-3 gonville-text-3 bravura-text-3 musejazz-text-3\
frametext ottava slurs-1 slurs-2 slurs-3 hairpins-1 pedal-1 line-1 line-2 line-3 line-4 gliss-1 gliss-2\
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 cross-1\
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Expand Up @@ -13,7 +13,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
emmentaler-text-1,gonville-text-1,bravura-text-1,musejazz-text-1, ^
emmentaler-text-2,gonville-text-2,bravura-text-2,musejazz-text-2, ^
emmentaler-text-3,gonville-text-3,bravura-text-3,musejazz-text-3, ^
frametext,ottava,slurs-1,slurs-2,slurs-3,hairpins-1,pedal-1,line-1,line-2,line-3,line-4,gliss-1,gliss-2, ^
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,cross-1, ^
Expand Down
Binary file added vtest/line-5-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/line-5.mscz
Binary file not shown.