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

Natural, smooth and zoom-relative scrolling #6700

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

Conversation

allejok96
Copy link
Contributor

Scrolling overhaul - a.k.a please make zooming usable for me 😿

  • Handle smooth scrolling trackpads and mice gracefully (supersedes #6220)
  • Only allow macOS natural scrolling in places where it makes sense
  • Scrolling in editors is relative to zoom level
  • Minimum scroll speed of Knob and Fader is at least 1% per wheel step
  • Only scroll MDI area on empty space or scrollbars
  • Discard horizontal scroll in places where it shouldn't be
  • Fix bug when scrolling on empty MidiClip
  • Remove shift+scroll in favor of Qt's built-in alt+scroll 😱 (see #5169)

Much of the above is done through the use of a single helper function, inspired by Qt's docs and internal code.

knob->incValue(verticalScroll(event, 10));  // scrolling increases knob by 10

Fixes maybe?

Things to test

  • Scrolling in editors + modifier keys
  • Scroll speed of editors at different zoom levels
  • Scrolling on widgets like combo box
  • Scroll speed of knob and fader
  • Natural scrolling on Mac
  • Touch pad scrolling

src/gui/editors/AutomationEditor.cpp Outdated Show resolved Hide resolved
src/gui/ScrollHelpers.cpp Outdated Show resolved Hide resolved



// TODO: is there a good way to prevent calling this method multiple times with the same event?
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines +46 to +47
static int xRemainder;
static int yRemainder;
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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:

  1. Scroll knob A 90% of a step - nothing happens.
  2. Scroll knob B.
  3. Scroll knob A slightly - it turns over.
  4. User is surprised, because it's impossible to keep track of the scroll remainder of every knob.

Global counter - the simple solution:

  1. Scroll knob A 90% of a step - nothing happens.
  2. Scroll knob B slightly - it turns over.
  3. 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:

  1. Scroll up 90% of a step - nothing happens.
  2. Scroll down 10% - nothing happens.
  3. Scroll up 90% - nothing happens.

@tresf
Copy link
Member

tresf commented May 6, 2023

@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.

@tresf
Copy link
Member

tresf commented May 6, 2023

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).

*
* 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);
Copy link
Contributor Author

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...

Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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());

Copy link
Member

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

Copy link
Contributor Author

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

@allejok96
Copy link
Contributor Author

Now the functions should handle the differing Alt modifier behavior of macOS and Windows. I hope my use of QFlags isn't awful.

@allejok96
Copy link
Contributor Author

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 ❤️

@luzpaz
Copy link
Contributor

luzpaz commented Jul 26, 2023

Anyone able to pick up the mantle on this ?

@DomClark DomClark added the needs takeover The original author is looking for someone else to continue this pull request label Aug 23, 2023
@tresf tresf mentioned this pull request May 21, 2024
26 tasks
@regulus79
Copy link
Contributor

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.

@tresf
Copy link
Member

tresf commented Jan 17, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs takeover The original author is looking for someone else to continue this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window Scrollbar Scrolls Performed With Mouse Wheel Scrolls Entire LMMS Window Scrollbar
8 participants