fix #29311 Fixed single selection to range selection transition.

This commit is contained in:
Bartlomiej Lewandowski 2014-06-30 13:05:28 +02:00
parent aa7957ba29
commit 559815b0cd

View file

@ -2831,38 +2831,40 @@ void Score::selectRange(Element* e, int staffIdx)
etick); etick);
} }
else if (_selection.isSingle()) { else if (_selection.isSingle()) {
Segment* seg = 0; Element* oe = selection().element();
Element* oe = _selection.element(); if (oe->type() == Element::Element::Type::NOTE || oe->isChordRest()) {
bool reverse = false; if (oe->type() == Element::Element::Type::NOTE)
int ticks = 0; oe = oe->parent();
if (oe->isChordRest())
ticks = static_cast<ChordRest*>(oe)->actualTicks(); ChordRest* cr = static_cast<ChordRest*>(oe);
int oetick = 0; int oetick = cr->segment()->tick();
if (oe->parent()->type() == Element::Type::SEGMENT) if (tick < oetick) {
oetick = static_cast<Segment*>(oe->parent())->tick(); _selection.setStartSegment(m->tick2segment(tick));
if (tick < oetick) if (etick >= oetick)
seg = m->first(); _selection.setEndSegment(m->last());
else if (etick >= oetick + ticks) { else
seg = m->last(); _selection.setEndSegment(cr->segment()->next1MM());
reverse = true; //change this to call nextSegmentAfterCR
}
else {
_selection.setStartSegment(cr->segment());
_selection.setEndSegment(m->last());
}
_selection.setStaffStart(staffIdx);
_selection.setStaffEnd(staffIdx + 1);
if(_selection.staffStart() > cr->staffIdx())
_selection.setStaffStart(cr->staffIdx());
else if (cr->staffIdx() >= _selection.staffEnd())
_selection.setStaffEnd(cr->staffIdx() + 1);
} }
int track = staffIdx * VOICES; else {
Element* el = 0; deselectAll();
// find first or last chord/rest in measure _selection.setRange(m->tick2segment(tick),
for (;;) { m == lastMeasure() ? 0 : m->last(),
el = seg->element(track); staffIdx,
if (el && el->isChordRest()) staffIdx + 1);
break;
if (reverse)
seg = seg->prev1MM();
else
seg = seg->next1MM();
if (!seg)
break;
} }
if (el)
select(el, SelectType::RANGE, staffIdx);
return;
} }
else { else {
qDebug("SELECT_RANGE: measure: sel state %hhd", _selection.state()); qDebug("SELECT_RANGE: measure: sel state %hhd", _selection.state());