diff --git a/libmscore/chord.cpp b/libmscore/chord.cpp index a6591cea55a8..fcc9c3fe339a 100644 --- a/libmscore/chord.cpp +++ b/libmscore/chord.cpp @@ -407,12 +407,13 @@ QPointF Chord::stemPosBeam() const // setSelected //--------------------------------------------------------- -void Chord::setSelected(bool f) +void Chord::setSelected(bool) { - Element::setSelected(f); +/* Element::setSelected(f); int n = _notes.size(); for (int i = 0; i < n; ++i) _notes.at(i)->setSelected(f); + */ } //--------------------------------------------------------- diff --git a/libmscore/cmd.cpp b/libmscore/cmd.cpp index 40271e350677..bfaca11ee66a 100644 --- a/libmscore/cmd.cpp +++ b/libmscore/cmd.cpp @@ -1044,7 +1044,7 @@ qDebug(" ChangeCRLen:: %d += %d(actual=%d)", tick, f2.ticks(), f2.ticks() * tim oc = cc; } if (first) { - select(oc, SelectType::SINGLE, 0); + // select(oc, SelectType::SINGLE, 0); first = false; } tick += oc->actualTicks(); diff --git a/libmscore/line.cpp b/libmscore/line.cpp index 9fcb875a449f..580789356614 100644 --- a/libmscore/line.cpp +++ b/libmscore/line.cpp @@ -778,7 +778,6 @@ void SLine::layout() } seg->layout(); } - adjustReadPos(); } diff --git a/libmscore/score.cpp b/libmscore/score.cpp index 97e09b010f90..0d85a0214d01 100644 --- a/libmscore/score.cpp +++ b/libmscore/score.cpp @@ -2635,13 +2635,12 @@ void Score::padToggle(Pad n) } } - Element* el = selection().element(); - if (el->type() == Element::Type::NOTE) - el = el->parent(); - if (!el->isChordRest()) + ChordRest* cr = selection().cr(); + if (!cr) return; - ChordRest* cr = static_cast(el); + deselectAll(); + if (cr->type() == Element::Type::CHORD && (static_cast(cr)->noteType() != NoteType::NORMAL)) { // // handle appoggiatura and acciaccatura @@ -2651,6 +2650,7 @@ void Score::padToggle(Pad n) } else changeCRlen(cr, _is.duration()); + } //--------------------------------------------------------- diff --git a/libmscore/select.cpp b/libmscore/select.cpp index c90bea8992a9..8bf72e127868 100644 --- a/libmscore/select.cpp +++ b/libmscore/select.cpp @@ -141,6 +141,19 @@ Element* Selection::element() const { return _el.size() == 1 ? _el[0] : 0; } +//--------------------------------------------------------- +// cr +//--------------------------------------------------------- + +ChordRest* Selection::cr() const + { + Element* e = element(); + if (e->type() == Element::Type::NOTE) + e = e->parent(); + if (e->isChordRest()) + return static_cast(e); + return 0; + } //--------------------------------------------------------- // activeCR @@ -214,8 +227,7 @@ ChordRest* Selection::lastChordRest(int track) const return 0; } ChordRest* cr = 0; - for (auto i = _el.begin(); i != _el.end(); ++i) { - Element* el = *i; + for (auto el : _el) { if (el->type() == Element::Type::NOTE) el = ((Note*)el)->chord(); if (el->isChordRest() && static_cast(el)->segment()->segmentType() == Segment::Type::ChordRest) { @@ -258,16 +270,32 @@ void Selection::deselectAll() updateState(); } +//--------------------------------------------------------- +// changeSelection +//--------------------------------------------------------- + +static QRectF changeSelection(Element* e, bool b) + { + QRectF r = e->canvasBoundingRect(); + e->setSelected(b); + r |= e->canvasBoundingRect(); + return r; + } + //--------------------------------------------------------- // clear //--------------------------------------------------------- void Selection::clear() { - foreach(Element* e, _el) { - _score->addRefresh(e->canvasBoundingRect()); - e->setSelected(false); - _score->addRefresh(e->canvasBoundingRect()); + for (Element* e : _el) { + if (e->isSpanner()) { // TODO: only visible elements should be selectable? + Spanner* sp = static_cast(e); + for (auto s : sp->spannerSegments()) + e->score()->addRefresh(changeSelection(s, false)); + } + else + e->score()->addRefresh(changeSelection(e, false)); } _el.clear(); _startSegment = 0; @@ -286,6 +314,7 @@ void Selection::clear() void Selection::remove(Element* el) { _el.removeOne(el); + qDebug("deselect1 %p <%s>", el, el->name()); el->setSelected(false); updateState(); } @@ -407,6 +436,7 @@ void Selection::appendChord(Chord* chord) void Selection::updateSelectedElements() { +qDebug("updateSelectedElements"); foreach(Element* e, _el) e->setSelected(false); _el.clear(); @@ -504,7 +534,7 @@ void Selection::setRange(Segment* startSegment, Segment* endSegment, int staffSt void Selection::update() { - foreach (Element* e, _el) + for (Element* e : _el) e->setSelected(true); updateState(); } diff --git a/libmscore/select.h b/libmscore/select.h index e39105baab91..32ac97994906 100644 --- a/libmscore/select.h +++ b/libmscore/select.h @@ -141,6 +141,7 @@ class Selection { void remove(Element*); void clear(); Element* element() const; + ChordRest* cr() const; Segment* firstChordRestSegment() const; ChordRest* firstChordRest(int track = -1) const; ChordRest* lastChordRest(int track = -1) const;