Skip to content

Commit 088c7ee

Browse files
iveshenry18Jojo-Schmitz
authored andcommitted
Check spanners when assessing emptiness
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. Port of musescore#8430, part 2
1 parent 589a7fb commit 088c7ee

File tree

3 files changed

+1533
-0
lines changed

3 files changed

+1533
-0
lines changed

src/engraving/rendering/dev/systemlayout.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
590590
staff_idx_t staffIdx = 0;
591591
bool systemIsEmpty = true;
592592

593+
Fraction stick = system->measures().front()->tick();
594+
Fraction etick = system->measures().back()->endTick();
595+
auto spanners = ctx.dom().spannerMap().findOverlapping(stick.ticks(), etick.ticks());
596+
593597
for (const Staff* staff : ctx.dom().staves()) {
594598
SysStaff* ss = system->staff(staffIdx);
595599

@@ -601,6 +605,12 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
601605
&& !(isFirstSystem && ctx.conf().styleB(Sid::dontHideStavesInFirstSystem))
602606
&& hideMode != Staff::HideMode::NEVER)) {
603607
bool hideStaff = true;
608+
for (auto spanner : spanners) {
609+
if (spanner.value->staff() == staff) {
610+
hideStaff = false;
611+
break;
612+
}
613+
}
604614
for (MeasureBase* m : system->measures()) {
605615
if (!m->isMeasure()) {
606616
continue;

src/engraving/rendering/stable/systemlayout.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
589589
staff_idx_t staffIdx = 0;
590590
bool systemIsEmpty = true;
591591

592+
Fraction stick = system->measures().front()->tick();
593+
Fraction etick = system->measures().back()->endTick();
594+
auto spanners = ctx.dom().spannerMap().findOverlapping(stick.ticks(), etick.ticks());
595+
592596
for (const Staff* staff : ctx.dom().staves()) {
593597
SysStaff* ss = system->staff(staffIdx);
594598

@@ -600,6 +604,12 @@ void SystemLayout::hideEmptyStaves(System* system, LayoutContext& ctx, bool isFi
600604
&& !(isFirstSystem && ctx.conf().styleB(Sid::dontHideStavesInFirstSystem))
601605
&& hideMode != Staff::HideMode::NEVER)) {
602606
bool hideStaff = true;
607+
for (auto spanner : spanners) {
608+
if (spanner.value->staff() == staff) {
609+
hideStaff = false;
610+
break;
611+
}
612+
}
603613
for (MeasureBase* m : system->measures()) {
604614
if (!m->isMeasure()) {
605615
continue;

0 commit comments

Comments
 (0)