Smooth Scrolling
AbandonedPublic

Authored by rmacmaster on Jan 13 2018, 2:37 PM.

Details

Reviewers
okular-devel
ngraham
Group Reviewers
Okular
Summary

I'm one of those guys that likes smooth scrolling on his PDF viewers.
I added two new settings: ScrollStep and SmoothScrolling.

ScrollStep changes the vertical scroll bar's scroll / step in pixels.
SmoothScrolling enables the smooth scrolling feature (disabled by default).

Test Plan

A better implementation might include changing the PageView to inherit the QAbstractItemView such that the built-in QT smooth scrolling could be used.
I'm not sure if this smooth scrolling would be better or worse.

The problem with the current implementation is that it sometimes continues scrolling even after the up/down key has been lifted.
This could be fixed with a timer similar to the DragScroll implementation.

For the moment, it's a basic smooth scrolling feature that works well when configured reasonably.

Diff Detail

Repository
R223 Okular
Lint
Lint Skipped
Unit
Unit Tests Skipped
rmacmaster created this revision.Jan 13 2018, 2:37 PM
Restricted Application added a project: Okular. · View Herald TranscriptJan 13 2018, 2:37 PM
Restricted Application added a subscriber: Okular. · View Herald Transcript
rmacmaster requested review of this revision.Jan 13 2018, 2:37 PM
ngraham added a subscriber: ngraham.EditedJan 13 2018, 3:47 PM

Awesome, I like smooth scrolling too, and would support its inclusion! But I wonder if this wouldn't be better implemented at the system level, to turn on smooth scrolling for all apps that use standard Qt scroll views. If that's not possible, then I guess this is fine.

Also, do we really need the scroll step control as part of this patch? That seems like a separate feature.

Also, congratulations on your first patch! If you need a hand with anything, feel free to contact me.

ngraham requested changes to this revision.Feb 16 2018, 4:11 AM

Finally got a chance to give this a whirl.

First, let's make sure we're talking about the same thing, because scroll terminology can otherwise be a bit imprecise:

  • Smooth scrolling: Scrolling using the scroll wheel, arrow keys, PageUp/PageDown keys, or the spacebar will results in an animated transition effect rather than the view "jumping" to the new location
  • Pixel scrolling: Doing a two-finger scroll gesture on a touchpad scrolls scroll pixel-by pixel proportionally with your fingers' movement, rather than the movement being interpreted as a scroll wheel and advancing the view by a fixed or user-configurable number of lines

Okular already does pixel scrolling, but does not do smooth scrolling. However, your patch also does not implement smooth scrolling; it allows the user to override the default number of "lines" per scroll wheel tick or arrow key press, and instead scroll by a user-configurable number of pixels.

Without tweaking the "Scroll Step" parameter, scrolling using the arrow keys, scroll wheel, or touchpad becomes interminably slow. Increasing Scroll Step gradually returns the behavior closer to the default.

As currently implemented, I'm not sure what value this adds to the typical Okular user. I played with the new setting a bunch but all of the values felt worse than the default. Can you maybe describe your use case, and what value this brings to you?

This revision now requires changes to proceed.Feb 16 2018, 4:11 AM
rmacmaster abandoned this revision.EditedFeb 16 2018, 4:43 AM

Sorry, I sort of abandoned this patch because I got caught up in other things.

* Smooth scrolling: Scrolling using the scroll wheel, arrow keys, PageUp/PageDown keys, or the spacebar will results in an animated transition effect rather than the view "jumping" to the new location 
* Pixel scrolling: Doing a two-finger scroll gesture on a touchpad scrolls scroll pixel-by pixel proportionally with your fingers' movement, rather than the movement being interpreted as a scroll wheel and advancing the view by a fixed or user-configurable number of lines

Originally, I was going for the first implementation, where users have the option to enable / disable the animation.
I was inspired by the Mozilla Firefox UI, which allows users to toggle "smooth scrolling" in their preferences with a checkbox option.

Smooth scrolling seems to be a controversial feature. Some people love it, but others really hate it and don't understand why others love it.
I'm one of those people who's addicted to his phone, so I've grown spoiled by mobile scrolling.
On a phone, you can hold your finger on the screen and drag the text line-by-line smoothly.
Okular's instant scrolling is a little hard on my eyes when I read text at different zoom levels.
Sometimes I need to hit the arrow key multiple times to feed a single line of text.
Sometimes one keystroke is too little, but two keystrokes is too much.

The patch I wrote is basic and filled with bugs.
It does two things poorly (controlling step size and animating the scroll).
This could possibly be solved by experimenting with the timers built into Okular, but a better approach is probably more along the lines of what you mentioned.
I think the responsibility of enabling smooth scrolling should fall on the Qt widgets rather than the Okular scroll event processing functions.
Qt has a QScrollBar widget. Perhaps a QSmoothScrollBar or an instance method with a boolean option to enable smooth scrolling could be added.
I'm running KDE on Debian, so I don't have a system setting I can change to universally enable smooth scrolling like those on Ubuntu might.

Step Size
Changing the step size might be a nice feature to add on its own.
It's simple and can be added as a configuration parameter with a default value of 20.
This would allow users to fiddle with the step size so that it works comfortably at their desired zoom level.
A step size of 20 may work well for 100% zoom, but what about 150%, 80%, full screen?

Here are some links showing demand for a smooth scrolling feature:
http://okular-devel.kde.narkive.com/ZM0xtQx4/okular-bug-319870-new-add-smooth-scrolling
https://askubuntu.com/questions/66489/is-there-a-way-to-enable-smooth-scrolling-for-pdfs