Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU3 Backend] Tweak staff hiding conditions for spanners #8527

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
iveshenry18 committed Jul 5, 2021
commit 37f993fac8f470709f4c561c6bafa5d82fa49971
5 changes: 3 additions & 2 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ void Score::hideEmptyStaves(System* system, bool isFirstSystem)

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

for (Staff* staff : qAsConst(_staves)) {
SysStaff* ss = system->staff(staffIdx);
Expand All @@ -1344,7 +1344,8 @@ void Score::hideEmptyStaves(System* system, bool isFirstSystem)
&& hideMode != Staff::HideMode::NEVER)) {
bool hideStaff = true;
for (auto spanner : spanners) {
if (spanner.value->staff() == staff) {
if (spanner.value->staff() == staff
&& !spanner.value->systemFlag()) {
hideStaff = false;
break;
}
Expand Down
108 changes: 80 additions & 28 deletions mtest/libmscore/layout/testStaffEmptiness.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
<Measure>
<voice>
<StaffText>
<text>Hanging Slur</text>
<text>Hanging Slur (unhides staff 2)</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
Expand Down Expand Up @@ -526,6 +526,10 @@
<Rest>
<durationType>quarter</durationType>
</Rest>
<StaffText>
<offset x="-10.8383" y="-3.22005"/>
<text>Staff 2 hidden</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
<Note>
Expand All @@ -545,6 +549,9 @@
<!-- Measure 21 -->
<Measure>
<voice>
<StaffText>
<text>Pedal line (unhides staff 2)</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
<Note>
Expand Down Expand Up @@ -606,9 +613,6 @@
<!-- Measure 24 -->
<Measure>
<voice>
<StaffText>
<text>Pedal Line</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
<Note>
Expand Down Expand Up @@ -815,9 +819,6 @@
</Measure>
<!-- Measure 31 -->
<Measure>
<LayoutBreak>
<subtype>line</subtype>
</LayoutBreak>
<voice>
<Rest>
<durationType>measure</durationType>
Expand All @@ -828,9 +829,6 @@
<!-- Measure 32 -->
<Measure>
<voice>
<StaffText>
<text>Ottava Line</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
<Note>
Expand Down Expand Up @@ -892,6 +890,9 @@
<!-- Measure 36 -->
<Measure>
<voice>
<StaffText>
<text>Ottava line (unhides staff 2)</text>
</StaffText>
<Chord>
<durationType>quarter</durationType>
<Note>
Expand Down Expand Up @@ -955,7 +956,20 @@
</Measure>
<!-- Measure 40 -->
<Measure>
<endRepeat>2</endRepeat>
<voice>
<Spanner type="Volta">
<Volta>
<endHookType>1</endHookType>
<beginText>1.</beginText>
<endings>1</endings>
</Volta>
<next>
<location>
<measures>1</measures>
</location>
</next>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
Expand All @@ -965,10 +979,36 @@
<!-- Measure 41 -->
<Measure>
<voice>
<Spanner type="Volta">
<prev>
<location>
<measures>-1</measures>
</location>
</prev>
</Spanner>
<Spanner type="Volta">
<Volta>
<endHookType>1</endHookType>
<beginText>2.</beginText>
<endings>2</endings>
</Volta>
<next>
<location>
<fractions>1/1</fractions>
</location>
</next>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
<Spanner type="Volta">
<prev>
<location>
<fractions>-1/1</fractions>
</location>
</prev>
</Spanner>
</voice>
</Measure>
</Staff>
Expand Down Expand Up @@ -1203,6 +1243,23 @@
<!-- Measure 21 -->
<Measure>
<voice>
<Spanner type="Pedal">
<Pedal>
<endHookType>1</endHookType>
<beginHookType>1</beginHookType>
<Segment>
<subtype>0</subtype>
<offset x="-1.65822" y="1.78426"/>
<off2 x="1.79962" y="0"/>
<minDistance>0.47426</minDistance>
</Segment>
</Pedal>
<next>
<location>
<measures>1</measures>
</location>
</next>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
Expand All @@ -1212,6 +1269,13 @@
<!-- Measure 22 -->
<Measure>
<voice>
<Spanner type="Pedal">
<prev>
<location>
<measures>-1</measures>
</location>
</prev>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
Expand All @@ -1230,17 +1294,6 @@
<!-- Measure 24 -->
<Measure>
<voice>
<Spanner type="Pedal">
<Pedal>
<endHookType>1</endHookType>
<beginHookType>1</beginHookType>
</Pedal>
<next>
<location>
<measures>1</measures>
</location>
</next>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
Expand All @@ -1250,13 +1303,6 @@
<!-- Measure 25 -->
<Measure>
<voice>
<Spanner type="Pedal">
<prev>
<location>
<measures>-1</measures>
</location>
</prev>
</Spanner>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
Expand Down Expand Up @@ -1495,6 +1541,12 @@
<tpc>18</tpc>
</Note>
</Chord>
<StaffText>
<placement>below</placement>
<minDistance>-999</minDistance>
<offset x="-11.5541" y="4.40686"/>
<text>Volta (should NOT unhide staff 1)</text>
</StaffText>
<Rest>
<durationType>quarter</durationType>
</Rest>
Expand Down