Skip to content

Commit d0fc8e9

Browse files
MarcSabatellavpereverzev
authored andcommitted
fix #315636: no space between barline and note with invisible signature
Resolves: https://musescore.org/en/node/315636 When code was added to better handle invisible key or time signatures at the beginning of a score, this inadvertently affected spacing between barline and first note if there were invisible key or time signature changes later. The spacing was never actually *correct* here - it was controlled by the key or time signature margin - but it more or less worked and scores depended on it. The problem is that the changes made involved setitng the width of these invisible segments to 0 and skipping them. Whereas previously, they got processed enough to yield some space betwene the barline and first note. The firx here is just to limit the effect of the previous change so not *all* segments with all elements invisible, but only those in system header measures, or segments after the beginning of the measure. Thus we continue to handle beginnings of scores and systems well, and also courtesies at the end of measures. But we revert to the previous behavior for key or time signatures at the beginning of measures that are *not* headers. Again, it wasn't ideal, but it basically worked, nand now works again the same way. I left TODO's in the code to indicate something of what would need to happen to fix this "for real", with the space controlled by barNoteDistance as the user expects, rather than depending on the key or time signature margins. A quick attempt to implement this led to problems that convinced me to put it off until a larger scale rewrite of the spacing algorithms as a whole.
1 parent cebc852 commit d0fc8e9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

libmscore/measure.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,13 +4432,21 @@ void Measure::computeMinWidth(Segment* s, qreal x, bool isSystemHeader)
44324432

44334433
while (s) {
44344434
s->rxpos() = x;
4435-
if (!s->enabled() || !s->visible() || s->allElementsInvisible()) {
4435+
// skip disabled / invisible segments
4436+
// segments with all elements invisible are skipped,
4437+
// but only for headers or segments later in the measure -
4438+
// invisible key or time signatures at the beginning of non-header measures are treated normally here
4439+
// otherwise we would not allocate enough space for the first note
4440+
// as it is, this isn't quite right as the space will be given by key or time margins,
4441+
// not the bar to note distance
4442+
// TODO: skip these segments entirely and get the correct bar to note distance
4443+
if (!s->enabled() || !s->visible() || ((header() || s->rtick().isNotZero()) && s->allElementsInvisible())) {
44364444
s->setWidth(0);
44374445
s = s->next();
44384446
continue;
44394447
}
44404448
Segment* ns = s->nextActive();
4441-
while (ns && ns->allElementsInvisible())
4449+
while (ns && ((header() || ns->rtick().isNotZero()) && ns->allElementsInvisible()))
44424450
ns = ns->nextActive();
44434451
// end barline might be disabled
44444452
// but still consider it for spacing of previous segment
@@ -4520,6 +4528,9 @@ void Measure::computeMinWidth()
45204528
//
45214529
// skip disabled segment
45224530
//
4531+
// TODO: skip segments with all elements invisible also
4532+
// this will eventually allow us to calculate correct bar to note distance
4533+
// even if there is an invisible key or time signature present
45234534
for (s = first(); s && !s->enabled(); s = s->next()) {
45244535
s->rxpos() = 0;
45254536
s->setWidth(0);

0 commit comments

Comments
 (0)