Skip to content

Commit

Permalink
Check spanners when assessing emptiness
Browse files Browse the repository at this point in the history
Port of musescore#8430, part 2:
Previously, a staff's emptiness was calculated based on its note and annotation content. Since this is evaluated before the system was laid out, the system did not have pointers to its SpannerSegments. This commit adds a way to include whether a staff has any spanners
(particularly pedal markings and hanging slurs) in
assessing emptiness, creating more consistent/expected hiding behavior in HideMode::AUTO.

Plus port of musescore#8527:
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 hen a spanner started on the first tick of the next system.

Plus fixing a regression with hairpins, resulting in the next system's staves to become unhidden
  • Loading branch information
iveshenry18 authored and Jojo-Schmitz committed Oct 11, 2023
1 parent 111ba8e commit 859a7f8
Show file tree
Hide file tree
Showing 3 changed files with 1,537 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/engraving/rendering/dev/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
staff_idx_t staffIdx = 0;
bool systemIsEmpty = true;

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

for (const Staff* staff : ctx.dom().staves()) {
SysStaff* ss = system->staff(staffIdx);

Expand All @@ -601,6 +605,14 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
&& !(isFirstSystem && ctx.conf().styleB(Sid::dontHideStavesInFirstSystem))
&& hideMode != Staff::HideMode::NEVER)) {
bool hideStaff = true;
for (auto spanner : spanners) {
if (spanner.value->staff() == staff
&& !spanner.value->systemFlag()
&& !spanner.value->isHairpin()) {
hideStaff = false;
break;
}
}
for (MeasureBase* m : system->measures()) {
if (!m->isMeasure()) {
continue;
Expand Down
12 changes: 12 additions & 0 deletions src/engraving/rendering/stable/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
staff_idx_t staffIdx = 0;
bool systemIsEmpty = true;

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

for (const Staff* staff : ctx.dom().staves()) {
SysStaff* ss = system->staff(staffIdx);

Expand All @@ -600,6 +604,14 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
&& !(isFirstSystem && ctx.conf().styleB(Sid::dontHideStavesInFirstSystem))
&& hideMode != Staff::HideMode::NEVER)) {
bool hideStaff = true;
for (auto spanner : spanners) {
if (spanner.value->staff() == staff
&& !spanner.value->systemFlag()
&& !spanner.value->isHairpin()) {
hideStaff = false;
break;
}
}
for (MeasureBase* m : system->measures()) {
if (!m->isMeasure()) {
continue;
Expand Down
Loading

0 comments on commit 859a7f8

Please sign in to comment.