Skip to content

Commit

Permalink
fix #29911
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Aug 26, 2014
1 parent 662cf87 commit 4cc20f8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 40 deletions.
2 changes: 1 addition & 1 deletion libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2747,7 +2747,7 @@ bool Measure::isMeasureRest(int staffIdx)
}
else {
strack = staffIdx * VOICES;
etrack = staffIdx * VOICES + VOICES;
etrack = strack + VOICES;
}
for (Segment* s = first(Segment::Type::ChordRest); s; s = s->next(Segment::Type::ChordRest)) {
for (int track = strack; track < etrack; ++track) {
Expand Down
90 changes: 51 additions & 39 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,42 +447,58 @@ void System::layout2()

int staffIdx = 0;
n = score()->parts().size();

for (Part* p : score()->parts()) {
SysStaff* s = staff(staffIdx);
SysStaff* s2;
int nstaves = p->nstaves();
for (InstrumentName* t : s->instrumentNames) {
//
// override Text->layout()
//
qreal y1, y2;
switch (t->layoutPos()) {
default:
case 0: // center at part
y1 = s->bbox().top();
y2 = staff(staffIdx + nstaves - 1)->bbox().bottom();
break;
case 1: // center at first staff
y1 = s->bbox().top();
y2 = s->bbox().bottom();
break;
case 2: // center between first and second staff
y1 = s->bbox().top();
y2 = staff(staffIdx + 1)->bbox().bottom();
break;
case 3: // center at second staff
y1 = staff(staffIdx + 1)->bbox().top();
y2 = staff(staffIdx + 1)->bbox().bottom();
break;
case 4: // center between first and second staff
y1 = staff(staffIdx + 1)->bbox().top();
y2 = staff(staffIdx + 2)->bbox().bottom();
break;
case 5: // center at third staff
y1 = staff(staffIdx + 2)->bbox().top();
y2 = staff(staffIdx + 2)->bbox().bottom();
break;
if (s->show()) {
for (InstrumentName* t : s->instrumentNames) {
//
// override Text->layout()
//
qreal y1, y2;
switch (t->layoutPos()) {
default:
case 0: // center at part
y1 = s->bbox().top();
s2 = staff(staffIdx);
for (int i = staffIdx + nstaves - 1; i > 0; --i) {
SysStaff* s = staff(i);
if (s->show()) {
s2 = s;
break;
}
}
y2 = s2->bbox().bottom();
break;
case 1: // center at first staff
y1 = s->bbox().top();
y2 = s->bbox().bottom();
break;

// TODO:
// sort out invisible staves

case 2: // center between first and second staff
y1 = s->bbox().top();
y2 = staff(staffIdx + 1)->bbox().bottom();
break;
case 3: // center at second staff
y1 = staff(staffIdx + 1)->bbox().top();
y2 = staff(staffIdx + 1)->bbox().bottom();
break;
case 4: // center between first and second staff
y1 = staff(staffIdx + 1)->bbox().top();
y2 = staff(staffIdx + 2)->bbox().bottom();
break;
case 5: // center at third staff
y1 = staff(staffIdx + 2)->bbox().top();
y2 = staff(staffIdx + 2)->bbox().bottom();
break;
}
t->rypos() = y1 + (y2 - y1) * .5 + t->textStyle().offset(t->spatium()).y();
}
t->rypos() = y1 + (y2 - y1) * .5 + t->textStyle().offset(t->spatium()).y();
}
staffIdx += nstaves;
}
Expand Down Expand Up @@ -545,7 +561,6 @@ void System::setInstrumentNames(bool longName)
int idx = 0;
foreach(const StaffName& sn, names) {
InstrumentName* iname = staff->instrumentNames.value(idx);

if (iname == 0) {
iname = new InstrumentName(score());
iname->setGenerated(true);
Expand Down Expand Up @@ -670,7 +685,6 @@ void System::add(Element* el)

void System::remove(Element* el)
{
//no! el->setParent(0);
switch (el->type()) {
case Element::Type::INSTRUMENT_NAME:
_staves[el->staffIdx()]->instrumentNames.removeOne(static_cast<InstrumentName*>(el));
Expand Down Expand Up @@ -994,12 +1008,10 @@ void System::scanElements(void* data, void (*func)(void*, Element*), bool all)

int idx = 0;
for (const SysStaff* st : _staves) {
if (!all && !(st->show() && score()->staff(idx)->show())) {
++idx;
continue;
if (all || st->show()) {
for (InstrumentName* t : st->instrumentNames)
func(data, t);
}
for (InstrumentName* t : st->instrumentNames)
func(data, t);
++idx;
}
for (SpannerSegment* ss : _spannerSegments) {
Expand Down

0 comments on commit 4cc20f8

Please sign in to comment.