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.
We get complaints from time to time about the canvas jumping during note input or other editing operations. Obviously some of this is intended and good, but there have been a few cases identified where I agree we are doing too much. See https://musescore.org/en/node/271271 for a recent forum discussion leading to this PR.
This PR is submitted against 2.3 because the whole canvas positioning seems more funamentally broken in master - I think maybe the width of the page in continuous view is wrong and throwing a lot of things off? But FWIW, the exact same code does compile and works as well as can be expected in master as well.
There are a few distinct changes here, separated into three different commits.
The first commit fixes something that is unquestionably a bug, a regression introduced in 2.2 that affects operations near the right margin in page view with vertical stacking of pages.
The second commit makes the canvas positioning more conservative in continuous view. Previously, any operation near either margin would cause an immediately jump all the way to the other side. This could make sense in some situations but really doesn't in others, as discussed in the forum post above. My changes here prevent the score jumping all the way to the right upon an operation near the right margin or all the way left upon an operation near the left margin. The only big jump I retain is during note entry, where the canvas will still reposition to the left when you near the right edge of the screen. Even here, though, I made it less aggressive, putting the target element 25% from the left edge of the screen rather than 5%. The idea is to keep more of the previous context in view. I also amended it to guarantee the previous and current note both remain in view, so even if we reduce that 25% back down to 5%, there will still be more context than before.
The final commit is a trial I don't recommend keeping as is, and there is a TODO in the code for this. Basically, I turned the "Pan score during playback" toggle button into "Pan score", period. So when disabled, there is no automatic canvas positioning whatsoever (at least, none done by adjustCanvasPosition). Some people swear they want that. I have my doubts, but I figure, get them a test build to see.
I welcome feedback! Probably best to discuss the behavior in the forum, the code here.