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

High resolution scrolling #6220

Closed
wants to merge 2 commits into from
Closed

Conversation

allejok96
Copy link
Contributor

Handle really sensitive scroll wheels (or touch pads) gracefully.

Problem

Most widgets only check if a scroll event is positive or negative, and scroll exactly one step. For mice like the MX master this may result in 7 steps per mouse wheel tick, because it has a wheel resolution of 2° (compared to standard 15°).

Solution

This PR implements a concise way to calculate scrolled steps, while keeping the remainder value, as suggested by the Qt docs. The remainder is discarded when the widget loses focus.

Widgets are updated to use this new counter logic. This means that editors, knobs and faders may be scrolled with a much finer precision using a hi-res mouse.

This also sets a new minimum scroll speed for knobs and faders (at most 200 steps form start to end). Scrolling really really fast on a standard mouse is also faster more accurate now.

Excuses

I've tried to build the counter in a way that using it would require as little code as possible, and no need to remember increasing, decreasing or resetting it. In other words, make it so you can't get it wrong.

  • Using ScrollCounter is cleaner than having an int member in each widget and doing the same calculation in 20 places.
  • ScrollCounter is a singleton because there is only one scroll wheel, so why would each widget have its own instance of it?
  • If a widget doesn't check the counter during event handling, the counter won't be increased. This prevents it from silently growing when scroll events are being ignored or propagated to the parent.
  • Also, thanks to the event filter, widgets never have to pass QWheelEvent to the counter.

As a side note, I've tried a way to intercept QWheelEvent and solve this problem higher up in the event chain. But this does not work due to how Qt does (undocumented) event propagation.

Bugs fixed in this PR

Other questionable changes

@LmmsBot
Copy link

LmmsBot commented Nov 19, 2021

🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩

Linux

macOS

Windows

🤖
{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://15233-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.152%2Bg08c175c48-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/15233?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://15230-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.152%2Bg08c175c48-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/15230?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://15232-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.152%2Bg08c175c48-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/15232?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://15231-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.152%2Bg08c175c48-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/15231?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/8ml673xylsowdwx6/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/41854652"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/nqkphoh4tetklxa1/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/41854652"}]}, "commit_sha": "4b1778610832623ea4579db52a298887e9c5f537"}

@qnebra
Copy link

qnebra commented Nov 20, 2021

For some reason MinGW build failed, but I guess you already notice it.

#3154 is annoying as hell when someone workflow had Song Editor at full screen. I am glad it gets fixed.

@allejok96
Copy link
Contributor Author

I tried building it locally with the lmmsci/linux.mingw32:18.04 container, and it worked just fine 😕

@qnebra
Copy link

qnebra commented Nov 23, 2021

Trying to build it locally, on Ubuntu 20.04 using MinGW it throws those errors:

[ 64%] Linking CXX shared module ../compressor.dll
/usr/bin/x86_64-w64-mingw32-ld: CMakeFiles/compressor.dir/objects.a(CompressorControlDialog.cpp.obj):CompressorControlDialog.cpp:(.text+0x247e): undefined reference to `ScrollCounter::getStepsY(float)'
/usr/bin/x86_64-w64-mingw32-ld: CMakeFiles/compressor.dir/objects.a(CompressorControlDialog.cpp.obj):CompressorControlDialog.cpp:(.text+0x7843): undefined reference to `ScrollCounter::registerWidget(QWidget*)'
collect2: error: ld returned 1 exit status
make[2]: *** [plugins/Compressor/CMakeFiles/compressor.dir/build.make:241: plugins/compressor.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:2712: plugins/Compressor/CMakeFiles/compressor.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 65%] Building CXX object plugins/Delay/CMakeFiles/delay.dir/__/Eq/moc_EqFader.cpp.obj
[ 65%] Linking CXX shared module ../crossovereq.dll
[ 65%] Built target crossovereq
[ 65%] Building CXX object plugins/Delay/CMakeFiles/delay.dir/qrc_delay.cpp.obj
[ 65%] Linking CXX shared module ../delay.dll
[ 65%] Built target delay
make: *** [Makefile:152: all] Error 2

Clean master was compiled correctly, without issues.

@allejok96
Copy link
Contributor Author

It's a long shot, but what if you change line 32 in include/ScrollCounter.h to

#include "lmms_export.h"
class LMMS_EXPORT ScrollCounter: public QObject

@qnebra
Copy link

qnebra commented Nov 23, 2021

It's a long shot, but what if you change line 32 in include/ScrollCounter.h to

#include "lmms_export.h"
class LMMS_EXPORT ScrollCounter: public QObject

It fixes compilation

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.

3 participants