Skip to content

Commit

Permalink
Check spanners when assessing emptiness
Browse files Browse the repository at this point in the history
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
  • Loading branch information
iveshenry18 authored and Jojo-Schmitz committed Oct 11, 2023
1 parent 5129738 commit 35921b8
Show file tree
Hide file tree
Showing 3 changed files with 1,533 additions and 0 deletions.
10 changes: 10 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());

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

Expand All @@ -601,6 +605,12 @@ 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) {
hideStaff = false;
break;
}
}
for (MeasureBase* m : system->measures()) {
if (!m->isMeasure()) {
continue;
Expand Down
10 changes: 10 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());

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

Expand All @@ -600,6 +604,12 @@ 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) {
hideStaff = false;
break;
}
}
for (MeasureBase* m : system->measures()) {
if (!m->isMeasure()) {
continue;
Expand Down
Loading

0 comments on commit 35921b8

Please sign in to comment.