Skip to content

Commit

Permalink
fix #29736
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Aug 18, 2014
1 parent cf9a633 commit 01ebb2e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ void Score::cmdAddSpanner(Spanner* spanner, const QPointF& pos)
return;
}

// all spanners live in voice 0 (except slurs/ties)
int track = staffIdx == -1 ? -1 : staffIdx * VOICES;

spanner->setTrack(track);
spanner->setTrack2(track);

Expand Down
3 changes: 3 additions & 0 deletions libmscore/ottava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ QVariant Ottava::propertyDefault(P_ID propertyId) const
case P_ID::END_TEXT_STYLE:
return QVariant::fromValue(score()->textStyle(TextStyleType::OTTAVA));

case P_ID::END_HOOK:
return true;

default:
return TextLine::propertyDefault(propertyId);
}
Expand Down
36 changes: 36 additions & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3468,5 +3468,41 @@ ChordRest* Score::findCR(int tick, int track) const
return nullptr;
}

//---------------------------------------------------------
// findCRinStaff
// find chord/rest <= tick in staff
//---------------------------------------------------------

ChordRest* Score::findCRinStaff(int tick, int track) const
{
Measure* m = tick2measureMM(tick);
if (!m) {
qDebug("findCR: no measure for tick %d", tick);
return nullptr;
}
// attach to first rest all spanner when mmRest
if (m->isMMRest())
tick = m->tick();
Segment* s = m->first(Segment::Type::ChordRest);
int strack = (track / VOICES) * VOICES;
int etrack = strack + VOICES;
int actualTrack = strack;

for (Segment* ns = s; ; ns = ns->next(Segment::Type::ChordRest)) {
if (ns == 0 || ns->tick() > tick)
break;
for (int t = strack; t < etrack; ++t) {
if (ns->element(t)) {
s = ns;
actualTrack = t;
break;
}
}
}
if (s)
return static_cast<ChordRest*>(s->element(actualTrack));
return nullptr;
}

}

1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ class Score : public QObject {
void addSpanner(Spanner*);

ChordRest* findCR(int tick, int track) const;
ChordRest* findCRinStaff(int tick, int track) const;
void layoutSpanner();
void insertTime(int tickPos, int tickLen);

Expand Down
7 changes: 5 additions & 2 deletions libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ void Spanner::computeStartElement()
{
switch (_anchor) {
case Anchor::SEGMENT:
_startElement = score()->findCR(tick(), track());
if (type() == Element::Type::SLUR)
_startElement = score()->findCR(tick(), track());
else
_startElement = score()->findCRinStaff(tick(), track());
break;

case Anchor::MEASURE:
Expand All @@ -415,7 +418,7 @@ void Spanner::computeEndElement()
_endElement = s ? static_cast<ChordRest*>(s->element(track2())) : nullptr;
}
else
_endElement = score()->findCR(tick2() - 1, track2());
_endElement = score()->findCRinStaff(tick2() - 1, track2());
break;

case Anchor::MEASURE:
Expand Down

0 comments on commit 01ebb2e

Please sign in to comment.