fix #93006: layout shift due to overestimating size of courtesy keysig #2361
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.
Last year we (mostly @mgavioli ) fixed a number of issues that were causing inconsistencies in layout, with a typical symptom being that each time you pressed Ctrl+A, one measure would move back and forth from one system to the next, with a correspond ripple effect on layout from that point on. These issues all had to do with how we accounted for the width of courtesy elements - clefs, key and time signatures.
In the process of fixing these, I introduced some code that almost but not quite worked:
25e43f2
It works well if there is only one staff, but the more staves, the more the code overestimates the width of courtesy key signatures, because I keep adding leftMargin to the accumulated max width on every iteration of the loop rather than only adding it to the current width. So the more staves a piece has, the more we overestimate the width of courtesy elements, leading us to think a measure will fit that won't or vice versa.