fix #285535, fix #284613: spacing of mid-measure clefs #5020
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://musescore.org/en/node/285535
The main issue here was a seemingly innocuous change to the alignment of clefs within their segment for the sake of palette display, but it ended up breaking mid-measure clef layout for scores with multiple staves. That's because previously clefs had negative positions and hence could overlap notes on other staves just as accidentals can - the segment shapes don't collide. But after that change, we ended up with bad spacing because layout would not allow the clefs to overlap the notes on other staves:
Fixing this in clef.cpp, however, uncovered another problem, where clefs would not longer tuck in over notes on the same staff:
versus the expected (in 3.0.5, anyhow, and ignore the collision with the beam in both cases, which is unrelated):
It's not as big a deal - and it was essentially the same in 2.3.2 - but since the whole "shape" scheme was supposed to allow for this, it did seem worth addressing. It turns out to have an interesting solution - Segment::minHorizontalDistance needs to be allowed to return negative values. It fixes this case, and I'm hoping it might turn out to also allow tighter spacing in other similar cases. So far I don't see any regressions from this, but more testing it definitely in order. [EDIT: see below, breaths needed to not return negative values, fixed now]
Here is how the original example now looks (more or less same as 2.3.2):