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

Add horizontal scrolling to MainWindow QMdiArea #5174

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

Conversation

Veratil
Copy link
Contributor

@Veratil Veratil commented Sep 6, 2019

WIP Fix for #5169.

My first attempt was to capture MainWindow's wheelEvent but there were times when that wouldn't capture the event properly. I took the step to subclass QMdiArea just to capture wheelEvents for this purpose.

Currently scrolling works unless you are hovering over the Song Editor or Piano Roll. I'm looking into how to handle those cases.

Vertical and horizontal scrolling will double speed when using the Control key. I haven't looked into how much more this should be, but it's a modifier to the scroll wheel angle delta. Subtraction is used because of positive/negative angle delta values for scrolling backwards/forwards.

By Qt's documentation, most mouse steps are 15 degrees (what I get when I scroll is +/-15), but some may be smaller. In those cases this will scroll slower, so we could use a constant number or figure out another approach to use.

I'm not certain if this will work on track pad's scrolling, I don't have one to test with.

@Veratil
Copy link
Contributor Author

Veratil commented Sep 11, 2019

I've made the wheelEvent ignored if scrolling won't do anything in the Song Editor and Piano Roll which properly bubbles up to MainWindow.

Only issue right now that I can't see why it's happening is in the Song Editor when horizontal scrolling is at the limits it will scroll up/down even with Shift held. I'm not sure if this is a bug with Qt or LMMS's handling of the event.

@Spekular
Copy link
Member

Vertical scroll worked before you added this, no? I assume something like this is happening:

  • Horizontal scrolling hits it's limit
  • Since horizontal scrolling isn't possible, scroll event "bubbles up"
  • Whatever handler performed vertical scroll before this PR is still active "above" yours and recieves the bubbled message
  • Vertical scroll happens as it used to

I could be wrong, but I don't think you need a new class + scroll handler to allow horizontal scroll. You should be able to override the scroll handling in the relevant class, I think? Maybe you could check for shift, delegate to the super handler if it doesn't exist, and then only handle the shift case...

@Spekular
Copy link
Member

Essentially, I'd guesd that wheelEvent bubbles up to SomeClass, and then bubbles from SomeClass to MainWindow. SomeClass probably ignores the event when vertical scroll isn't possible.

@Veratil
Copy link
Contributor Author

Veratil commented Sep 11, 2019

Vertical scroll worked before you added this, no?

I actually didn't test if this was before behavior, but it's improper IMO either way.

I could be wrong, but I don't think you need a new class + scroll handler to allow horizontal scroll. You should be able to override the scroll handling in the relevant class, I think?

I tried this first, you can see in my opening comment about my tests with it.

@Veratil
Copy link
Contributor Author

Veratil commented Sep 11, 2019

I believe I've found the cause. TrackContainerView handles the event first, then passes it to SongEditor.

	// always pass wheel-event to parent-widget (song-editor
	// bb-editor etc.) because they might want to use it for zooming
	// or scrolling left/right if a modifier-key is pressed, otherwise
	// they do not accept it and we pass it up to QScrollArea
	m_trackContainerView->wheelEvent( _we );

Once it's ignored in SongEditor it returns to TrackContainerView which since it's ignored it passes it to its QScrollArea::wheelEvent which scrolls it up/down until it can't, which then passes up to the QMdiArea of MainWindow.

I believe if I add the horizontal scroll to this area it should fix the issue, and I'll have to make sure it doesn't mess anything else up. 😩

@Veratil
Copy link
Contributor Author

Veratil commented Sep 20, 2019

So after some debugging, I've found that QAbstractScrollArea::wheelEvent is still using the now obsolete orientation() which isn't handling the event properly.

void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
{
    Q_D(QAbstractScrollArea);
    if (e->orientation() == Qt::Horizontal)
        QApplication::sendEvent(d->hbar, e);
    else
        QApplication::sendEvent(d->vbar, e);
}

Getting the e->orientation() returns Qt::Vertical, but getting e->modifiers() returns 0x2000000 which is Qt::ShiftModifier. AFAICT this means the orientation for the event isn't getting set correctly anymore. So I've modified TrackContainerView to create a new QWheelEvent copying everything from the original, only changing the orientation to Qt::Horizontal and it handles the scrolling properly.

@Veratil
Copy link
Contributor Author

Veratil commented Sep 21, 2019

@PhysSong @Reflexe I believe I have this at a good point enough to remove WIP. I've tested with subwindows as much as I can think that this should touch, and it seems to be working as intended.

@PhysSong PhysSong changed the title WIP: Add horizontal scrolling to MainWindow QMdiArea Add horizontal scrolling to MainWindow QMdiArea Sep 21, 2019
@Veratil Veratil added needs code review A functional code review is currently required for this PR needs style review A style review is currently required for this PR needs testing This pull request needs more testing and removed in progress labels Apr 19, 2020
@Veratil Veratil requested a review from JohannesLorenz April 19, 2020 22:06
@JohannesLorenz JohannesLorenz removed their request for review May 19, 2020 05:23
@Veratil Veratil mentioned this pull request Aug 14, 2020
@LmmsBot
Copy link

LmmsBot commented Jan 17, 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! 🎩

Windows

Linux

macOS

🤖
{"platform_name_to_artifacts": {"Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://12165-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.67%2Bg709d40221-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/12165?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://12164-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.67%2Bg709d40221-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/12164?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/i81mvwga0o3ck4oh/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/37303169"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/gbgin9yvbyb5g31p/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/37303169"}], "Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://12161-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.67%2Bg709d402-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/12161?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://12162-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.67%2Bg709d40221-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/12162?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "ca59482b299691eef7ff3922a9de952fc65f55a2"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review A functional code review is currently required for this PR needs style review A style review is currently required for this PR needs testing This pull request needs more testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants