Layout jump due to bad cautionaryWidth() calculation
Windows 10, GIT commit: c90a7e0
This is a followup to #109021: Hairpin and other symbols are shifting when relayout occurs. As I imagined, there *are* other cases where you can get the same sort of layout shift on first relayout after load, with presumably the same "wandering hairpin" type of side effects. The problem with the score in that issue was with widths of repeat barlines. But there is also a problem with double bars generated as part of a courtesy key signature. You can see it with the attached score:
1) Load, verify measure 3 is at end of first system
2) press Ctrl+A
Result: measure 3 jumps to the next system
This happens because our estimate of the width of the courtesy key signature that would be needed in order to fit measure 3 at the end of the first system does not account for the double bar that also gets added. It shouldn't be too hard to add this to cautionaryWidth(). We just need to do a similar thing as we do for the key signature itself - check across all staves to make sure there isn't one already, then keep a running "max" value to figure out the widest the generated barline would end up being.
Attachment | Size |
---|---|
cautionaryWidth.mscx | 15.01 KB |
Comments
With the following file, the layout jumps back and forth on each Ctrl+A, due to the same cause. Actually, it does on the other too, but I'm attaching this to remind us to consider multiple staves and the possibility of different barlines on each, which is trickier than it seems at first. But I do have a tentative fix.
Here's work in progress. Seems to do the right thing for full-sizes staves regardless of *score* scaling, but there are issues if a staff is less than full size. I *think* that is separate from the barline issue - like we aren't calculating the size of courtesy key signature itself (or its margin) correctly. Not sure. Feel free to investigate further.
https://github.com/MarcSabatella/MuseScore/commit/348a5d51b462199366828…
Been playing around with this more, it definitely improves things at lot. Probably not 100% perfect, and every once in a while I still see a slight discrepancy in calculated widths after layout with some combinations of barline types and staff scaling - not by enough to cause a jump, though. And then when I try again, I can't reproduce the discrepancy at all.
In any case, the more common case where all staves are the same size and have the same barline type definitely seems to work well.
I actually added the commit about to the same branch as my previous PR and thought that would show up in the PR, but it didn't. Do I need to submit a new one? Or does someone else want to take this code and play with it a bit more and submit one themselves?
You will need to reopen a PR.
https://github.com/musescore/MuseScore/pull/3058
Fixed in branch 2.1, commit 40f86c31b4
fix #180991: layout jump due to courtesy keysig barline
Fixed in branch 2.1, commit 49bf4ddc8e
Merge pull request #3058 from MarcSabatella/180991-jump-courtesy-barline
fix #180991: layout jump due to courtesy keysig barline
Unfortunately, it looks like the fix for this or for #109021: Hairpin and other symbols are shifting when relayout occurs or #180286: Pushing a system with an horizontal frame causes layout problem created a brand new layout jump: #181656: Regression: insert an horizontal frame leads to bad layout on undo
Automatically closed -- issue fixed for 2 weeks with no activity.