Skip to content

Commit

Permalink
fixes for slur editing
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 8, 2014
1 parent 200e58e commit f97c0a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
22 changes: 10 additions & 12 deletions libmscore/edit.cpp
Expand Up @@ -1396,9 +1396,7 @@ void Score::deleteItem(Element* el)
Chord* chord = static_cast<Chord*>(el);
removeChordRest(chord, false);

// replace with rest if voice 0 or if in tuplet
Tuplet* tuplet = chord->tuplet();
// if ((el->voice() == 0 || tuplet) && (chord->noteType() == NoteType::NORMAL)) {
// replace with rest
if (chord->noteType() == NoteType::NORMAL) {
Rest* rest = new Rest(this, chord->durationType());
rest->setDurationType(chord->durationType());
Expand All @@ -1409,7 +1407,7 @@ void Score::deleteItem(Element* el)
Segment* segment = chord->segment();
undoAddCR(rest, segment->measure(), segment->tick());

// undoAddElement(rest);
Tuplet* tuplet = chord->tuplet();
if (tuplet) {
tuplet->add(rest);
rest->setTuplet(tuplet);
Expand Down Expand Up @@ -2074,16 +2072,16 @@ void Score::removeChordRest(ChordRest* cr, bool clearSegment)
QList<Segment*> segments;
for (Element* e : cr->linkList()) {
undo(new RemoveElement(e));
Segment* s = cr->segment();
if (!segments.contains(s))
segments.append(s);
}
if (clearSegment) {
for (Segment* s : segments) {
if (s->isEmpty())
undo(new RemoveElement(s));
if (clearSegment) {
Segment* s = cr->segment();
if (!segments.contains(s))
segments.append(s);
}
}
for (Segment* s : segments) {
if (s->isEmpty())
undo(new RemoveElement(s));
}
if (cr->beam()) {
Beam* beam = cr->beam();
if (beam->generated()) {
Expand Down
16 changes: 8 additions & 8 deletions libmscore/slur.cpp
Expand Up @@ -764,10 +764,10 @@ void Slur::slurPosChord(SlurPos* sp)

void Slur::slurPos(SlurPos* sp)
{
if (anchor() == Anchor::CHORD) {
slurPosChord(sp);
return;
}
// if (anchor() == Anchor::CHORD) {
// slurPosChord(sp);
// return;
// }
qreal _spatium = spatium();

if (endCR() == 0) {
Expand All @@ -780,10 +780,10 @@ void Slur::slurPos(SlurPos* sp)
return;
}

ChordRest* scr = startCR();
ChordRest* ecr = endCR();
Chord* sc = 0;
Note* note1 = 0;
ChordRest* scr = startCR();
ChordRest* ecr = endCR();
Chord* sc = 0;
Note* note1 = 0;
if (startCR()->type() == Element::Type::CHORD) {
sc = static_cast<Chord*>(startCR());
note1 = _up ? sc->upNote() : sc->downNote();
Expand Down
2 changes: 2 additions & 0 deletions libmscore/spanner.cpp
Expand Up @@ -431,6 +431,7 @@ Chord* Spanner::startChord()
Q_ASSERT(_anchor == Anchor::CHORD);
if (!_startElement)
_startElement = score()->findCR(tick(), track());
Q_ASSERT(_startElement->type() == Element::Type::CHORD);
return static_cast<Chord*>(_startElement);
}

Expand All @@ -457,6 +458,7 @@ Chord* Spanner::endChord()
if (_endElement->type() != Element::Type::CHORD)
_endElement = nullptr;
}
Q_ASSERT(_endElement->type() == Element::Type::CHORD);
return static_cast<Chord*>(_endElement);
}

Expand Down
7 changes: 7 additions & 0 deletions libmscore/undo.cpp
Expand Up @@ -1376,6 +1376,13 @@ RemoveElement::RemoveElement(Element* e)
Score* score = element->score();
if (element->isChordRest()) {
// remove any slurs pointing to this chor/rest
for (auto i : score->spanner()) { // TODO: dont search whole list
Spanner* s = i.second;
if (s->type() == Element::Type::SLUR && (s->startElement() == e || s->endElement() == e)) {
score->undoRemoveElement(s);
}
}

ChordRest* cr = static_cast<ChordRest*>(element);
if (cr->tuplet() && cr->tuplet()->elements().empty())
score->undoRemoveElement(cr->tuplet());
Expand Down

0 comments on commit f97c0a4

Please sign in to comment.