Skip to content

Commit 0b338b4

Browse files
asattelyJojo-Schmitz
authored andcommitted
Fix GH#9007 - Invisible key/time signatures having adverse effect on spacing
Backport of musescore#9137 (needs parts of musescore#9068)
1 parent 9284edc commit 0b338b4

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

libmscore/measure.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3487,11 +3487,11 @@ void Measure::stretchMeasure(qreal targetWidth)
34873487
std::multimap<qreal, Segment*> springs;
34883488

34893489
Segment* seg = first();
3490-
while (seg && !seg->enabled())
3490+
while (seg && (!seg->enabled() || seg->allElementsInvisible()))
34913491
seg = seg->next();
34923492
qreal minimumWidth = seg ? seg->x() : 0.0;
34933493
for (Segment& s : _segments) {
3494-
if (!s.enabled() || !s.visible())
3494+
if (!s.enabled() || !s.visible() || s.allElementsInvisible())
34953495
continue;
34963496
Fraction t = s.ticks();
34973497
if (t.isNotZero()) {
@@ -3536,7 +3536,7 @@ void Measure::stretchMeasure(qreal targetWidth)
35363536
//---------------------------------------------------
35373537

35383538
Segment* s = first();
3539-
while (s && !s->enabled())
3539+
while (s && (!s->enabled() || s->allElementsInvisible()))
35403540
s = s->next();
35413541
qreal x = s ? s->pos().x() : 0.0;
35423542
while (s) {
@@ -4454,21 +4454,17 @@ void Measure::computeMinWidth(Segment* s, qreal x, bool isSystemHeader)
44544454

44554455
while (s) {
44564456
s->rxpos() = x;
4457-
// skip disabled / invisible segments
4458-
// segments with all elements invisible are skipped,
4459-
// but only for headers or segments later in the measure -
4460-
// invisible key or time signatures at the beginning of non-header measures are treated normally here
4461-
// otherwise we would not allocate enough space for the first note
4462-
// as it is, this isn't quite right as the space will be given by key or time margins,
4463-
// not the bar to note distance
4464-
// TODO: skip these segments entirely and get the correct bar to note distance
4465-
if (!s->enabled() || !s->visible() || ((header() || s->rtick().isNotZero()) && s->allElementsInvisible())) {
4457+
// segments with all elements invisible are skipped, though these are already
4458+
// skipped in computeMinWidth() -- the only way this would be an issue here is
4459+
// if this method was called specifically with the invisible segment specified
4460+
// which I'm pretty sure doesn't happen at this point. still...
4461+
if (!s->enabled() || !s->visible() || s->allElementsInvisible()) {
44664462
s->setWidth(0);
44674463
s = s->next();
44684464
continue;
44694465
}
44704466
Segment* ns = s->nextActive();
4471-
while (ns && ((header() || ns->rtick().isNotZero()) && ns->allElementsInvisible()))
4467+
while (ns && ns->allElementsInvisible())
44724468
ns = ns->nextActive();
44734469
// end barline might be disabled
44744470
// but still consider it for spacing of previous segment
@@ -4547,15 +4543,10 @@ void Measure::computeMinWidth()
45474543
{
45484544
Segment* s;
45494545

4550-
//
45514546
// skip disabled segment
4552-
//
4553-
// TODO: skip segments with all elements invisible also
4554-
// this will eventually allow us to calculate correct bar to note distance
4555-
// even if there is an invisible key or time signature present
4556-
for (s = first(); s && !s->enabled(); s = s->next()) {
4557-
s->rxpos() = 0;
4558-
s->setWidth(0);
4547+
for (s = first(); s && (!s->enabled() || s->allElementsInvisible()); s = s->next()) {
4548+
s->rxpos() = computeFirstSegmentXPosition(s); // this is where placement of hidden key/time sigs is set
4549+
s->setWidth(0); // it shouldn't affect the width of the bar no matter what it is
45594550
}
45604551
if (!s) {
45614552
setWidth(0.0);

0 commit comments

Comments
 (0)