Skip to content

Commit

Permalink
fix #36511
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 22, 2014
1 parent 802b800 commit cf92afb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
5 changes: 3 additions & 2 deletions libmscore/chord.cpp
Expand Up @@ -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);
*/
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/cmd.cpp
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion libmscore/line.cpp
Expand Up @@ -778,7 +778,6 @@ void SLine::layout()
}
seg->layout();
}

adjustReadPos();
}

Expand Down
10 changes: 5 additions & 5 deletions libmscore/score.cpp
Expand Up @@ -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<ChordRest*>(el);
deselectAll();

if (cr->type() == Element::Type::CHORD && (static_cast<Chord*>(cr)->noteType() != NoteType::NORMAL)) {
//
// handle appoggiatura and acciaccatura
Expand All @@ -2651,6 +2650,7 @@ void Score::padToggle(Pad n)
}
else
changeCRlen(cr, _is.duration());

}

//---------------------------------------------------------
Expand Down
44 changes: 37 additions & 7 deletions libmscore/select.cpp
Expand Up @@ -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<ChordRest*>(e);
return 0;
}

//---------------------------------------------------------
// activeCR
Expand Down Expand Up @@ -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<ChordRest*>(el)->segment()->segmentType() == Segment::Type::ChordRest) {
Expand Down Expand Up @@ -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<Spanner*>(e);
for (auto s : sp->spannerSegments())
e->score()->addRefresh(changeSelection(s, false));
}
else
e->score()->addRefresh(changeSelection(e, false));
}
_el.clear();
_startSegment = 0;
Expand All @@ -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();
}
Expand Down Expand Up @@ -407,6 +436,7 @@ void Selection::appendChord(Chord* chord)

void Selection::updateSelectedElements()
{
qDebug("updateSelectedElements");
foreach(Element* e, _el)
e->setSelected(false);
_el.clear();
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions libmscore/select.h
Expand Up @@ -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;
Expand Down

0 comments on commit cf92afb

Please sign in to comment.