-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Natural, smooth and zoom-relative scrolling #6700
base: master
Are you sure you want to change the base?
Conversation
src/gui/ScrollHelpers.cpp
Outdated
|
||
|
||
|
||
// TODO: is there a good way to prevent calling this method multiple times with the same event? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are we calling it multiple times? I don't seem to see any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For diagonal scroll events, Qt 5 generates two events(one for vertical, the other for horizontal) for Qt 4 compatibility. AFAIK, this isn't the case in Qt 6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insight @PhysSong, I was wondering about that. This is not a problem atm, but I was thinking about fool proofing. I tried to make it clear in the doc string, but you know.... people. If called improperly the counter will be double increased and it will be hard to detect.
static int xRemainder; | ||
static int yRemainder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of these being static. The value will carry over to another event and might cause unintended scroll values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but per-widget counters might be useful for fractional parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered this a lot... My conclusion is: does it really matter?
Per-widget counter - the logical solution:
- Scroll knob A 90% of a step - nothing happens.
- Scroll knob B.
- Scroll knob A slightly - it turns over.
- User is surprised, because it's impossible to keep track of the scroll remainder of every knob.
Global counter - the simple solution:
- Scroll knob A 90% of a step - nothing happens.
- Scroll knob B slightly - it turns over.
- User is surprised, because it's impossible to keep track of the scroll remainder of every knob.
Another thing: the remainder is reset every time the wheel changes direction. This is how Qt handles it and it's a clever way to prevent offsets building up over time and also pretty logical when you think about it. But it comes with this side effect:
- Scroll up 90% of a step - nothing happens.
- Scroll down 10% - nothing happens.
- Scroll up 90% - nothing happens.
@allejok96 it's very nice to now have the trackpad on MacOS capable of changing knobs! One initial observation though is clicking and dragging UP/DOWN raises and lowers them, however swiping UP/DOW on the track pad lowers and raises them. Is this intended? Note, MacOS uses "natural" scrolling by default, and I currently have this enabled. |
Another issue... prior to this, on Mac, holding Shift would allow the scroll wheel to switch from up/down scrolling to left/right scrolling. This PR seems to have removed that and I can't figure out a replacement key(s). |
include/ScrollHelpers.h
Outdated
* | ||
* Returns a positive value if the top of the wheel is moved to the left | ||
*/ | ||
int LMMS_EXPORT horizontalScroll(const QWheelEvent* event, const float factor = 1, const bool allowNatural = true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tresf changing to allowNatural = false
in these two places should fix the issue of natural scrolling on knobs. I'll get around to fixing it later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this change belong in Knob.cpp
instead? Anyway, I tried it and it has no effect.
Possibly related: #5507 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 Could you add a printf
somewhere to see if QWheelEvent->inverted()
is true? On Linux it's not detected. If we can't know if the scroll is natural or not I guess the only way is having a setting for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, if you don't mind being more specific; there's no (obvious) place to add...
printf(QWheelEvent->inverted());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got it...
model()->incValue(verticalScroll(we, scrollFactor) - horizontalScroll(we, scrollFactor));
+ printf("Inverted: %d\n", we->inverted());
s_textFloat->setText( displayValue() );
Shows:
Inverted: 1
Inverted: 1
Inverted: 1
Inverted: 1
Inverted: 1
Inverted: 1
Inverted: 1
Inverted: 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope the last commit fixed this
Now the functions should handle the differing Alt modifier behavior of macOS and Windows. I hope my use of QFlags isn't awful. |
Fellow devs, I have decided to take a break from coding to pursue other things because it's been getting too much lately and apparently my life balancing skills sucks. I'll just leave the PRs open and if anyone feels like it they can pick it up from there. Sorry, I know it's abrupt but sometimes you have to be ❤️ |
Anyone able to pick up the mantle on this ? |
Is this PR still active? I apologize, I may have accidentally worked over you by implementing scrolling relative to zoom level in #7476. But this PR looks way cleaner and more general, so please feel free to discard my changes. |
The OP took a break so no worries. This PR has over a dozen file conflicts, so a new PR should probably be used over this one. |
Scrolling overhaul - a.k.a please make zooming usable for me 😿
Much of the above is done through the use of a single helper function, inspired by Qt's docs and internal code.
Fixes maybe?
Things to test