YACReader / yacreader

This repo contains the code of YACReader's desktop version.
https://www.yacreader.com
GNU General Public License v3.0
992 stars 94 forks source link

[Request] Smooth scrolling with arrow keys #275

Open ajakka opened 3 years ago

ajakka commented 3 years ago

Hi YAC Devs, I think the title gives it out already but I'd love it if arrow navigation in YAC would be as smouth as mouse scrolling. I switched from other proprietary software for sometime now, and never regretted it, I liked using every feature you guys put effort into implementing. That's the only thing I feel is missing the YAC experience.

Thank you.

selmf commented 3 years ago

Yes, arrow-key scrolling is a bit sub-optimal, but this is actually the stock Qt behavior. Mouse wheels generate more input and have a finer resolution, so this is directly mapped to the scrolling and the result is smooth. To achieve a similar experience using arrow keys you need to add a lot more boiler plate code dealing with acceleration, de-acceleration, involved mathematics and the related research how humans perceive this input.

This means that this involves a good amount of testing, trial-and-error and we generally have to invent part of the wheel ourselves, even if we can adapt solutions from other Qt apps.

The good news is that even if the finer details are tricky, this should be doable by subclassing the involved Qt class and adding the metrics we need, so the general impact on our code base is minimal.

If you are interested, I can point you to some material and examples on how to best approach this. If not, you will need to be a bit patient as we will probably tackle this feature as part of a larger refactoring/rewrite of the viewer code involving some more advanced features.

ajakka commented 3 years ago

Sure, I'd love it if you could share such resources with me so I can tinker with it.

Thanks @selmf for the informative answer :)

selmf commented 3 years ago

@ajakka it's been some time since I last researched this, so I am a bit rusty. The last time I talked about this with @luisangelsm we considered looking into QSmoothScrollArea . This is a class which can add different kinds of smooth scrolling to the standard Qt QScrollArea class. The license is GPL2 though and the author did not explicitly state that a later version like YACReader's GPL3 can be used, so there would be some clarification needed if we want to use this directly.

To get a gauge of the challenges involved in getting this right, I recommend scrolling with pleasure by Pavel Fatin, which is a quite extensive writeup. When reading this, take into consideration that Qt already does a lot of these things or provides the requirements and our problem is defining a good behavior for the arrow keys.

There are likely more sources. KDE's document viewer Okular would be a good place to check and I also dimly remember reading interesting things about this in news about libinput, which is used to handle user input for Linux these days - but mostly for stuff like trackpoint and trackpad acceleration. There is also a good chance that there are research articles on how a user would perceive different approaches.

Long story short, this is a project where you could go from some quick hacking to writing a thesis, depending on how deep you want to dive into the rabbit hole.

ajakka commented 3 years ago

Thank @selmf, I'll definitely tinker with it and see, I might end up writing a thesis 😁