musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.08k stars 2.6k forks source link

Inconsistent scrollbar in palettes #11528

Open jessjwilliamson opened 2 years ago

jessjwilliamson commented 2 years ago

Describe the bug A strange scrollbar bug when scrolling through 'Bagpipe embellishments' in palettes. This specific category has the longest vertical list which causes strange scrollbar behaviour. So far only tested using a mouse wheel, unsure about the trackpad yet.

To Reproduce Steps to reproduce the behaviour:

  1. Go to pallettes
  2. Click on 'Bagpipe embellishments' and expand the category
  3. Scroll down through palettes
  4. See bug

Expected behaviour A consistent scrollbar throughout the whole vertical palettes section.

Screenshots

https://user-images.githubusercontent.com/71656189/166907822-b8742e4a-7a79-44bd-b392-a46105d3407a.mp4

llui85 commented 2 years ago

This is also an issue in MU3. Additional context from https://github.com/musescore/MuseScore/issues/10085#issuecomment-1007350771:

Comment by cbjeukendrup:

Palettes have an additional problem. They make use of the QML ListView component. That component only loads the list items that are currently in the viewable area; items that are scrolled out of view are destroyed (to save memory) and will be recreated when they will get into the view again.

Because not all items are loaded at a time, the total height of the scrollable area cannot be calculated. It can only be estimated, which is what QML does: it takes the average height of all visible items, and then uses that height to estimate the total height.

This works perfectly fine if all list items have exactly the same height, which is the case in most list views. But in the Palettes, this is totally different: collapsed palettes are very small, while expanded palettes vary from tall to very tall. The estimated total height will be totally wrong. Also, it will change continuously while scrolling, because other items become visible, so the average height of the visible items changes. That causes jumping and other strange behaviour.

I'm not totally sure about a solution. One option would be to replace the ListView by a Flickable+Column+Repeater. I also believe that you can control the "cache size" of the ListView, so if that works, that would be another option.