Skip to content

Commit 80fe1c3

Browse files
iveshenry18Jojo-Schmitz
authored andcommitted
Tweak staff hiding conditions for spanners
This commit tweaks the changes from commit 54ebee4 (which checks for spanners when assessing staff emptiness) and ignores spanners that are "system" spanners (such as voltas or system text). This prevents a false-positive unhiding in the case of such system spanners. Also, it prevents another false positive that occurred when a spanner started on the first tick of the next system. Duplicate of musescore#8527
1 parent 0786557 commit 80fe1c3

File tree

2 files changed

+83
-30
lines changed

2 files changed

+83
-30
lines changed

libmscore/layout.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ void Score::hideEmptyStaves(System* system, bool isFirstSystem)
13311331

13321332
Fraction stick = system->measures().front()->tick();
13331333
Fraction etick = system->measures().back()->endTick();
1334-
auto spanners = score()->spannerMap().findOverlapping(stick.ticks(), etick.ticks());
1334+
auto spanners = score()->spannerMap().findOverlapping(stick.ticks(), etick.ticks() - 1);
13351335

13361336
for (Staff* staff : qAsConst(_staves)) {
13371337
SysStaff* ss = system->staff(staffIdx);
@@ -1345,7 +1345,8 @@ void Score::hideEmptyStaves(System* system, bool isFirstSystem)
13451345
&& hideMode != Staff::HideMode::NEVER)) {
13461346
bool hideStaff = true;
13471347
for (auto spanner : spanners) {
1348-
if (spanner.value->staff() == staff && !spanner.value->systemFlag()) {
1348+
if (spanner.value->staff() == staff
1349+
&& !spanner.value->systemFlag()) {
13491350
hideStaff = false;
13501351
break;
13511352
}

mtest/libmscore/layout/testStaffEmptiness.mscx

Lines changed: 80 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<Measure>
274274
<voice>
275275
<StaffText>
276-
<text>Hanging Slur</text>
276+
<text>Hanging Slur (unhides staff 2)</text>
277277
</StaffText>
278278
<Chord>
279279
<durationType>quarter</durationType>
@@ -526,6 +526,10 @@
526526
<Rest>
527527
<durationType>quarter</durationType>
528528
</Rest>
529+
<StaffText>
530+
<offset x="-10.8383" y="-3.22005"/>
531+
<text>Staff 2 hidden</text>
532+
</StaffText>
529533
<Chord>
530534
<durationType>quarter</durationType>
531535
<Note>
@@ -545,6 +549,9 @@
545549
<!-- Measure 21 -->
546550
<Measure>
547551
<voice>
552+
<StaffText>
553+
<text>Pedal line (unhides staff 2)</text>
554+
</StaffText>
548555
<Chord>
549556
<durationType>quarter</durationType>
550557
<Note>
@@ -606,9 +613,6 @@
606613
<!-- Measure 24 -->
607614
<Measure>
608615
<voice>
609-
<StaffText>
610-
<text>Pedal Line</text>
611-
</StaffText>
612616
<Chord>
613617
<durationType>quarter</durationType>
614618
<Note>
@@ -815,9 +819,6 @@
815819
</Measure>
816820
<!-- Measure 31 -->
817821
<Measure>
818-
<LayoutBreak>
819-
<subtype>line</subtype>
820-
</LayoutBreak>
821822
<voice>
822823
<Rest>
823824
<durationType>measure</durationType>
@@ -828,9 +829,6 @@
828829
<!-- Measure 32 -->
829830
<Measure>
830831
<voice>
831-
<StaffText>
832-
<text>Ottava Line</text>
833-
</StaffText>
834832
<Chord>
835833
<durationType>quarter</durationType>
836834
<Note>
@@ -892,6 +890,9 @@
892890
<!-- Measure 36 -->
893891
<Measure>
894892
<voice>
893+
<StaffText>
894+
<text>Ottava line (unhides staff 2)</text>
895+
</StaffText>
895896
<Chord>
896897
<durationType>quarter</durationType>
897898
<Note>
@@ -955,7 +956,20 @@
955956
</Measure>
956957
<!-- Measure 40 -->
957958
<Measure>
959+
<endRepeat>2</endRepeat>
958960
<voice>
961+
<Spanner type="Volta">
962+
<Volta>
963+
<endHookType>1</endHookType>
964+
<beginText>1.</beginText>
965+
<endings>1</endings>
966+
</Volta>
967+
<next>
968+
<location>
969+
<measures>1</measures>
970+
</location>
971+
</next>
972+
</Spanner>
959973
<Rest>
960974
<durationType>measure</durationType>
961975
<duration>4/4</duration>
@@ -965,10 +979,36 @@
965979
<!-- Measure 41 -->
966980
<Measure>
967981
<voice>
982+
<Spanner type="Volta">
983+
<prev>
984+
<location>
985+
<measures>-1</measures>
986+
</location>
987+
</prev>
988+
</Spanner>
989+
<Spanner type="Volta">
990+
<Volta>
991+
<endHookType>1</endHookType>
992+
<beginText>2.</beginText>
993+
<endings>2</endings>
994+
</Volta>
995+
<next>
996+
<location>
997+
<fractions>1/1</fractions>
998+
</location>
999+
</next>
1000+
</Spanner>
9681001
<Rest>
9691002
<durationType>measure</durationType>
9701003
<duration>4/4</duration>
9711004
</Rest>
1005+
<Spanner type="Volta">
1006+
<prev>
1007+
<location>
1008+
<fractions>-1/1</fractions>
1009+
</location>
1010+
</prev>
1011+
</Spanner>
9721012
</voice>
9731013
</Measure>
9741014
</Staff>
@@ -1203,6 +1243,23 @@
12031243
<!-- Measure 21 -->
12041244
<Measure>
12051245
<voice>
1246+
<Spanner type="Pedal">
1247+
<Pedal>
1248+
<endHookType>1</endHookType>
1249+
<beginHookType>1</beginHookType>
1250+
<Segment>
1251+
<subtype>0</subtype>
1252+
<offset x="-1.65822" y="1.78426"/>
1253+
<off2 x="1.79962" y="0"/>
1254+
<minDistance>0.47426</minDistance>
1255+
</Segment>
1256+
</Pedal>
1257+
<next>
1258+
<location>
1259+
<measures>1</measures>
1260+
</location>
1261+
</next>
1262+
</Spanner>
12061263
<Rest>
12071264
<durationType>measure</durationType>
12081265
<duration>4/4</duration>
@@ -1212,6 +1269,13 @@
12121269
<!-- Measure 22 -->
12131270
<Measure>
12141271
<voice>
1272+
<Spanner type="Pedal">
1273+
<prev>
1274+
<location>
1275+
<measures>-1</measures>
1276+
</location>
1277+
</prev>
1278+
</Spanner>
12151279
<Rest>
12161280
<durationType>measure</durationType>
12171281
<duration>4/4</duration>
@@ -1230,17 +1294,6 @@
12301294
<!-- Measure 24 -->
12311295
<Measure>
12321296
<voice>
1233-
<Spanner type="Pedal">
1234-
<Pedal>
1235-
<endHookType>1</endHookType>
1236-
<beginHookType>1</beginHookType>
1237-
</Pedal>
1238-
<next>
1239-
<location>
1240-
<measures>1</measures>
1241-
</location>
1242-
</next>
1243-
</Spanner>
12441297
<Rest>
12451298
<durationType>measure</durationType>
12461299
<duration>4/4</duration>
@@ -1250,13 +1303,6 @@
12501303
<!-- Measure 25 -->
12511304
<Measure>
12521305
<voice>
1253-
<Spanner type="Pedal">
1254-
<prev>
1255-
<location>
1256-
<measures>-1</measures>
1257-
</location>
1258-
</prev>
1259-
</Spanner>
12601306
<Rest>
12611307
<durationType>measure</durationType>
12621308
<duration>4/4</duration>
@@ -1495,6 +1541,12 @@
14951541
<tpc>18</tpc>
14961542
</Note>
14971543
</Chord>
1544+
<StaffText>
1545+
<placement>below</placement>
1546+
<minDistance>-999</minDistance>
1547+
<offset x="-11.5541" y="4.40686"/>
1548+
<text>Volta (should NOT unhide staff 1)</text>
1549+
</StaffText>
14981550
<Rest>
14991551
<durationType>quarter</durationType>
15001552
</Rest>

0 commit comments

Comments
 (0)