Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth Scrolling for Filemanager Lighttable #17341

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bastibe
Copy link
Contributor

@bastibe bastibe commented Aug 18, 2024

The file manager in the lighttable scrolls only in one-thumbnail increments. Thus feels clunky and disorienting compared to the smooth scrolling that is available if one drags the scroll bars.

This commit changes the file manager scroll behavior to scroll pixel-precise if scrolled with a precision touch pad. Normal "clicky" mouse wheel scroll behavior is unchanged.

The commit changes scroll events to be either, 1.0 or -1.0 from clicky mouse wheels, or any other floating point offset for precision touch pads. If a 1.0 or -1.0 is detected, the view is scrolled by full-thumbnail increments. If any other offset is detected, it is scrolled by that pixel amount.

The file manager in the lighttable scrolls only in one-thumbnail increments. Thus feels clunky and disorienting compared to the smooth scrolling that is available if one drags the scroll bars.

This commit changes the file manager scroll behavior to scroll pixel-precise if scrolled with a precision touch pad. Normal "clicky" mouse wheel scroll behavior is unchanged.

The commit changes scroll events to be either, 1.0 or -1.0 from clicky mouse wheels, or any other floating point offset for precision touch pads. If a 1.0 or -1.0 is detected, the view is scrolled by full-thumbnail increments. If any other offset is detected, it is scrolled by that pixel amount.
src/dtgtk/thumbtable.c Outdated Show resolved Hide resolved
@zisoft
Copy link
Collaborator

zisoft commented Aug 18, 2024

Works fine and smooth on macOS with trackpad and magic mouse.

@bastibe
Copy link
Contributor Author

bastibe commented Aug 18, 2024

I have only tested this on macOS so far, with both a magic track pad and a regular mouse with a clicky scroll wheel.

src/dtgtk/thumbtable.c Outdated Show resolved Hide resolved
@bastibe
Copy link
Contributor Author

bastibe commented Aug 18, 2024

On the plus side, mouse wheel scrolling on Windows works as intended. I'll look further into the touch pad scrolling behavior on Windows tomorrow.

It appears I misunderstood the scroll scaling for precision touch pads. The scaling does not appear to be macOS-specific, but should instead be applied to all precision touch events.
@bastibe
Copy link
Contributor Author

bastibe commented Aug 19, 2024

I changed the behavior of the scrolling to be platform-independent. It now seems to work fine on macOS and Windows.

@bastibe
Copy link
Contributor Author

bastibe commented Aug 19, 2024

Actually, my last commit was silly. It makes the scroll speed dependent on the thumbnail size. I'll fix it tomorrow, with a fixed factor.

no longer scales with thumbail size
@bastibe
Copy link
Contributor Author

bastibe commented Aug 23, 2024

As far as I can tell, the current state works well, both on macOS and Windows.

It is finished as far as I am concerned. Is there anything else you would like to have changed in order for this to get merged?

@TurboGit
Copy link
Member

TurboGit commented Sep 4, 2024

@bastibe : At the end what does that bring? Now I need to pay attention to the way I scroll to ensure that I have a full thumb visible. So I'm not convinced that it is a good move but I'm not strongly against either. Maybe you or some others will come with good arguments to have this merged?

@TurboGit
Copy link
Member

TurboGit commented Sep 4, 2024

@ralfbrown @jenshannoschwalm @victoryforce @AlicVB @wpferguson : What's your view on this? TIA.

@jenshannoschwalm
Copy link
Collaborator

I confess I don't have any rational opinion.

I think it comes down to "what user feel being natural" using those devices.

I personally felt everything being fine until now.

@bastibe
Copy link
Contributor Author

bastibe commented Sep 6, 2024

With a touch pad, there are no detents for single lines. Instead, the view "jumps" every so often as I drag my fingers down the touch pad. I find this actively disorienting in darktable, getting worse the larger the thumbnail size. Conversely, with a scroll wheel, it feels somewhat natural to me to scroll text line by line, and by extension, scroll thumbnails line by line. Although even there I find scrolling disorienting if the thumbnails are large.

As a point of comparison, modern text editor widgets (VSCode, Sublime Text, Obsidian, Thunderbird, Word) all scroll fractional lines, even with a "clicky" mouse wheel. Even inside darktable, the file picker used for selecting images in "copy & import" in the lighttable, and the collections list on the left side of the lighttable, scroll smoothly with fractional lines, even with a mouse wheel. With a touch pad, all of these support pixel-precise "tactile" scrolling, which this PR adds to the lighttable view.

The file managers in the various operating systems may be an interesting point of comparison, especially when looking at a directory full of image files in grid view, thus mimicking darktable's lighttable view: macOS scrolls such a directory smoothly and fractionally, regardless of input device. Windows' file Explorer scrolls smoothly with a touch pad, and row-by-row with a scroll wheel, exactly like this PR. As an interesting side note, the Windows Explorer aligns the top row of images to the top of the window while scrolling up, and the bottom row while scrolling down; leaving the respective other end with a fractional thumbnail. It's slightly odd, but also kind of neat.

For what it's worth, DigiKam, Adobe Lightroom, Capture One, Apple Photos, and DxO Photo Lab all scroll their lighttable-equivalent view fractionally and smoothly, regardless of input device. RawTherapee scrolls smoothly and fractionally with a touch pad, but line-by-line (without aligning to full images) with a mouse wheel, just like this PR.

So I think the default these days for a grid of images is to scroll smoothly and fractionally. Some applications additionally provide a line-by-line mode if a scroll wheel is used (Windows Explorer and RawTherapee).

@AlicVB
Copy link
Contributor

AlicVB commented Sep 6, 2024

I have to admit that I'm not really fond of this change with a mouse, as it tend to slow down scrolling and I prefer when thumbs are fully visible on top (that last point is clearly subjective, though)
That said, it clearly solve a bug for touchpad. Do you think it's feasible to differentiate the behavior depending on the input device ?

  • touchpad : smooth scrolling (to solve the bug)
  • mouse : legacy behavior (which doesn't seem to annoy user)

@TurboGit
Copy link
Member

TurboGit commented Sep 6, 2024

Ok if not possible or too difficult to differentiate the input device a preference that user can activate or not

@bastibe
Copy link
Contributor Author

bastibe commented Sep 7, 2024

Maybe I wasn't clear enough: This PR does not change anything about the mouse scrolling behavior. The scroll wheel still scrolls by one full rows of thumbnails for every detent in the scroll wheel. Thumbnails still perfectly align with the top of the window. There should be no change whatsoever to before.

Only if a fractional scroll event is triggered does it scroll fractionally. As far as I know, this only happens for touch pads. (Unless there are scroll wheels that issue fractional scroll events? Mine don't. Does anyone know if some scroll wheels issue fractional scroll events?)

@zisoft
Copy link
Collaborator

zisoft commented Sep 7, 2024

Does anyone know if some scroll wheels issue fractional scroll events?)

My Logitech mouse on my Mac. I need 3 ticks of the wheel to get a visual response. IMO this is an annoying behavior which breaks the connection between the device and the UI. The first two steps simply do nothing, the third step makes the lighttable to scroll one row of the thumbnails.

A preference setting for this would be great for me.

@TurboGit
Copy link
Member

TurboGit commented Sep 7, 2024

Maybe I wasn't clear enough: This PR does not change anything about the mouse scrolling behavior. The scroll wheel still scrolls by one full rows of thumbnails for every detent in the scroll wheel. Thumbnails still perfectly align with the top of the window. There should be no change whatsoever to before.

That's not what I see hence my comment. On my side I need to scoll multiple time to have a full thumbnail line moved top or bottom.

@bastibe
Copy link
Contributor Author

bastibe commented Sep 7, 2024

Oh, I am terribly sorry about that! I was not aware of such behavior.

Is there some way to detect the presence of a mouse wheel instead of a touch scroll? Or is this somehow related to the scroll wheel speed in the operating system?

Otherwise, would you be ok with making this a preference? A hint on how to add a preference would be appreciated, but I can probably figure it out myself as well.

@AlicVB
Copy link
Contributor

AlicVB commented Sep 7, 2024

Oh, I am terribly sorry about that! I was not aware of such behavior.

That's not a problem. That's what the test phase is for.
On my side, with a Logitech mouse, it doesn't move row by row either...

RawTherapee scrolls smoothly and fractionally with a touch pad, but line-by-line (without aligning to full images) with a mouse wheel, just like this PR.

We should check if it works for us and copy-paste their code ;)

@bastibe
Copy link
Contributor Author

bastibe commented Sep 8, 2024

We should check if it works for us and copy-paste their code ;)

Could someone with one of those Logitech mice check if RawTherapee actually behaves like that for you (scrolls row-by-row)? I suspect that it will scroll fractionally, just like with this PR.

If that's true, I propose to add a preference for switching between row-by-row and pixel-precise-fractional, regardless of input device. Perhaps that should have been the implementation to begin with, instead of trying to make conjectures about input devices based on scroll-event metadata.

@TurboGit
Copy link
Member

TurboGit commented Sep 8, 2024

I have a Logitech M705 and I have a fractionally scroll with RawTherapee indeed.

@bastibe
Copy link
Contributor Author

bastibe commented Sep 9, 2024

Thank you! I'll look into implementing a preference then.

previously, the lighttable either scrolled smoothly if a precision scroll event was registered (scroll value is != 1 or -1), or row-by-row if it was clicky (scroll value is 1 or -1). This former is typically issued by touch pads, where smooth scrolling is common behavior. The latter for clicky mouse scroll wheels with clear detents.

However, it appears that some mice with clicky wheels still issue floating scroll events, and smooth scrolling. This behavior did not feel good.

Therefore, this commit makes the choice between smooth scrolling and clicky scrolling a preference instead, and no longer tries to infer "correct" scrolling behavior from a scroll increment heuristic.
@bastibe
Copy link
Contributor Author

bastibe commented Sep 10, 2024

I've updated the PR to make scrolling behavior a preference (enable smooth scrolling for lighttable thumbnails):

image

Kudos to you developers of darktable: figuring out how to add a preference was incredibly simple. What a fantastic piece of software!

@Donatzsky
Copy link

Instead of the on/off checkbox, perhaps a dropdown with on, off and auto could be better. Auto would then choose depending on the detected input event.

@TurboGit
Copy link
Member

Auto would then choose depending on the detected input event.

As discussed above we don't know how to have this auto. If it was possible we wouldn't have even bothered to add a preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants