diff --git a/libmscore/system.cpp b/libmscore/system.cpp index 260dbefe461b..7c560a6e8bda 100644 --- a/libmscore/system.cpp +++ b/libmscore/system.cpp @@ -1285,28 +1285,30 @@ qreal System::bottomDistance(int staffIdx, const SkylineLine& s) const // firstVisibleSysStaff //--------------------------------------------------------- -SysStaff* System::firstVisibleSysStaff() const +int System::firstVisibleSysStaff() const { - for (SysStaff* s : _staves) { - if (s->show()) - return s; + int nstaves = _staves.size(); + for (int i = 0; i < nstaves; ++i) { + if (_staves[i]->show()) + return i; } qDebug("no sys staff"); - return 0; + return -1; } //--------------------------------------------------------- // lastVisibleSysStaff //--------------------------------------------------------- -SysStaff* System::lastVisibleSysStaff() const +int System::lastVisibleSysStaff() const { - for (int i = _staves.size() - 1; i >= 0; --i) { + int nstaves = _staves.size(); + for (int i = nstaves - 1; i >= 0; --i) { if (_staves[i]->show()) - return _staves[i]; + return i; } qDebug("no sys staff"); - return 0; + return -1; } //--------------------------------------------------------- @@ -1316,7 +1318,8 @@ SysStaff* System::lastVisibleSysStaff() const qreal System::minTop() const { - SysStaff* s = firstVisibleSysStaff(); + int si = firstVisibleSysStaff(); + SysStaff* s = si < 0 ? nullptr : staff(si); if (s) return -s->skyline().north().max(); return 0.0; @@ -1331,7 +1334,8 @@ qreal System::minBottom() const { if (vbox()) return vbox()->bottomGap(); - SysStaff* s = lastVisibleSysStaff(); + int si = lastVisibleSysStaff(); + SysStaff* s = si < 0 ? nullptr : staff(si); if (s) return s->skyline().south().max() - s->bbox().height(); return 0.0; @@ -1344,11 +1348,10 @@ qreal System::minBottom() const qreal System::spacerDistance(bool up) const { - SysStaff* ss = up ? firstVisibleSysStaff() : lastVisibleSysStaff(); - if (!ss) + int staff = up ? firstVisibleSysStaff() : lastVisibleSysStaff(); + if (staff < 0) return 0.0; qreal dist = 0.0; - int staff = ss->idx; for (MeasureBase* mb : measures()) { if (mb->isMeasure()) { Measure* m = toMeasure(mb); diff --git a/libmscore/system.h b/libmscore/system.h index 5bc9b7879688..089d325e26a8 100644 --- a/libmscore/system.h +++ b/libmscore/system.h @@ -51,7 +51,7 @@ class SysStaff { bool _show { true }; // derived from Staff or false if empty // staff is hidden public: - int idx { 0 }; + //int idx { 0 }; QList instrumentNames; const QRectF& bbox() const { return _bbox; } @@ -89,8 +89,8 @@ class System final : public Element { mutable bool fixedDownDistance { false }; qreal _distance; // temp. variable used during layout - SysStaff* firstVisibleSysStaff() const; - SysStaff* lastVisibleSysStaff() const; + int firstVisibleSysStaff() const; + int lastVisibleSysStaff() const; int getBracketsColumnsCount(); void setBracketsXPosition(const qreal xOffset); diff --git a/vtest/gen b/vtest/gen index 216b1047b9d4..71d80fcf4438 100755 --- a/vtest/gen +++ b/vtest/gen @@ -58,7 +58,7 @@ else beams-11 beams-12 beams-13 beams-14 beams-15 beams-16 beams-17\ user-offset-1 user-offset-2 chord-space-1 chord-space-2 tablature-1 image-1\ lyrics-1 lyrics-2 lyrics-3 lyrics-4 lyrics-5 lyrics-6 lyrics-7 lyrics-8 voice-1 voice-2 slash-1 slash-2\ - system-1 system-2 system-3 system-4 system-5 system-6 system-7 hide-1 small-1 tremolo-1\ + system-1 system-2 system-3 system-4 system-5 system-6 system-7 system-8 hide-1 small-1 tremolo-1\ staff-1 staff-2 layout-1 layout-2 layout-3 layout-4 layout-5 layout-6 layout-7 layout-8 layout-9 layout-10\ articulation-1\ percussion-grace\ diff --git a/vtest/gen.bat b/vtest/gen.bat index 36ea878a9411..05c97f596690 100644 --- a/vtest/gen.bat +++ b/vtest/gen.bat @@ -36,7 +36,7 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres beams-11,beams-12,beams-13,beams-14,beams-15,beams-16,beams-17, ^ user-offset-1,user-offset-2,chord-space-1,chord-space-2,tablature-1,image-1, ^ lyrics-1,lyrics-2,lyrics-3,lyrics-4,lyrics-5,lyrics-6,lyrics-7,lyrics-8,voice-1,voice-2,slash-1,slash-2, ^ - system-1,system-2,system-3,system-4,system-5,system-6,system-7,hide-1,small-1,tremolo-1, ^ + system-1,system-2,system-3,system-4,system-5,system-6,system-7,system-8,hide-1,small-1,tremolo-1, ^ staff-1,staff-2,layout-1,layout-2,layout-3,layout-4,layout-5,layout-6,layout-7,layout-8,layout-9,layout-10, ^ articulation-1, ^ percussion-grace, ^ diff --git a/vtest/system-8.mscx b/vtest/system-8.mscx new file mode 100644 index 000000000000..8187f216d838 --- /dev/null +++ b/vtest/system-8.mscx @@ -0,0 +1,299 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 1 + + + + + + + + + + + + + + + stdNormal + + + 1 + + + + stdNormal + + F + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + + + + + + + + + + quarter + + 72 + 14 + + + + quarter + + + half + + + + + + line + + + + quarter + + 72 + 14 + + + + quarter + + + half + + + + + + + quarter + + 72 + 14 + + + + quarter + + + half + + + + + + line + + + + quarter + + 72 + 14 + + + + quarter + + + half + + + + + + + + + quarter + + 48 + 14 + + + + quarter + + + half + + + + + + + quarter + + 48 + 14 + + + + quarter + + + half + + + + + 20 + + + staff spacer down + + + quarter + + 48 + 14 + + + + quarter + + + half + + + + + + + quarter + + 48 + 14 + + + + quarter + + + half + + + + + + diff --git a/vtest/system-8.png b/vtest/system-8.png new file mode 100644 index 000000000000..5a44fa6e88a3 Binary files /dev/null and b/vtest/system-8.png differ