Chord symbol spacing issues
We're making good progress on chord symbols, but here are some related spacing issues. Could conceivably be four separate changes need to fix, but I think it would be good to look at them together. I suspect the first is an easy fix, the second might not be fixable before release, but we'll see.
Look at the following:
In the first measure, there is obviously way too much space allocated for the chord symbol name. I am betting that is because we are allocating the entire width of the chord symbol to the right-hand side of the note shape, even though the chord is centered. Hopefully an easy fix. Note that in the second measure, I tried left-aligning the chord symbol, and now there isn't quite enough space allocated. That's because the D is centered but the code is allocating shape for that second note with the same flaw. Left-aligning the D finally fixes it, as shown in the third measure.
That's what happens if chord symbols are attached to adjacent notes. Now let's look at what happens in the case where the notes aren't adjacent, or when there are no notes at all for one or both chords:
Here, the approach of adding space to the notes fails, because we aren't checking for note collisions. In the first measure, it's because the notes aren't adjacent; in the second it is because there is no note shape at all for the second chord. So no extra space is allocated, and instead the autoplace kicks in instead, thus pushing the second chord above the first. better than nothing, I guess, but 2.x would have done the right thing, which is to space the notes to avoid the collision (it did this by doing a separate pass for chord symbol spacing as opposed to note spacing). I'm not sure these will be so easy to fix without re-implementing the two-pass approach, which I doubt actually makes sense at this point.
Comments
Here's a test file to reproduce the above easily.
First case is indeed easy, I just stole the code from lyrics layout just above in ChordRest::shape(), which seems to work fine.
https://github.com/musescore/MuseScore/pull/4282
Fixed in branch master, commit 4161a1fbe7
partial fix #279259: chord symbol spacing
Fixed in branch master, commit a660098acc
Merge pull request #4282 from MarcSabatella/horizontal-spacing
partial fix #279259: chord symbol spacing
partially fixed (first case). I would focus on the second case and postpone fixing the third one.
I am not sure how to go about either, but at least for both of these, increasing stretch as necessary is a workaround.
BTW, my change had an interesting side effect, now long chord symbols on the first note of a measure add space before the first note - they don't overlap the barline. That's not necessarily a bad thing, but will become more of a non-issue when I change the default to left align...
Since it has come up a couple of times lately, and I was just looking at this section of code for something else, I'm thinking about this again.
Turns out that adding to the chordrest shape is already handling collisions both between non-adjacent segments ("second case"), which I am pretty sure it wasn't when that code was added originally. I think maybe this change for lyrics caused it to start working: https://github.com/musescore/MuseScore/commit/54eab63a7f6027b183d987efe….
The one thing we're still not catching is segments with no chordrests ("third case"). But, if we add the chord symbol to the segment shape, this suddenly starts working too! This is easily done by deleting the line excluding harmony objects from being added in Segment::createShapes().
There are some glitches I'm seeing as the layout of harmony elements is still very fragile, happening as it does in different places at different times. Especially when using jazz style, where the raw bbox is very different from the formatted one. So we can't make the one-line change and call it done. But if someone wanted to work on this, it's probably not too far from working already.
BTW, this could also be our ticket to avoiding the "stair step" problem on other element types too, except we'd need to deal with them as part of the chordrest shape calculation just as we do for lyrics and chord symbols. A bigger change, but something to think about.
https://github.com/musescore/MuseScore/pull/4773
Review appreciated, but I think this will be good.
Fixed in branch master, commit b4019070ee
fix #279259: chord symbol spacing fixes
Fixed in branch master, commit 07a2ad3306
_Merge pull request #4773 from MarcSabatella/279259-chord-symbol-spacing
fix #279259: chord symbol spacing_
Automatically closed -- issue fixed for 2 weeks with no activity.