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

GraphicsView: Implement pinch to zoom #477

Merged
merged 12 commits into from Jul 24, 2019
Merged

Conversation

@jeffwheeler
Copy link
Contributor

jeffwheeler commented Jul 4, 2019

This pull request is addresses #474.

The code in the initial pull request should not be merged, but is an initial example. I'd like to figure out how to make it work across platforms and with a mouse.

jeffwheeler added 5 commits Jul 3, 2019
@jeffwheeler

This comment has been minimized.

Copy link
Contributor Author

jeffwheeler commented Jul 4, 2019

I have updated the pull request with a set of commits that I think should behave nicely for everyone.

I don't believe we need a preference setting to configure this. My intent is to leave mice behavior unchanged (including on Mac), but fix the currently broken trackpad behavior. I don't think anyone would want the existing trackpad behavior.

The commit fails CI on Ubuntu 14.04, I think because of an ancient version of Qt. Is that something you're interested in supporting? Canonical has dropped support for that platform already.

Copy link
Member

ubruhin left a comment

Thanks for the PR! :)

I found some issues and have some questions/suggestions, see comments below.

The commit fails CI on Ubuntu 14.04, I think because of an ancient version of Qt. Is that something you're interested in supporting? Canonical has dropped support for that platform already.

As long as it's easy, I'd like to keep support for Qt 5.2. So far it was always very easy to keep this support, so I saw no reason to drop it. One of LibrePCB's goals is the availability on many different systems (architectures, operating systems, distributions etc.). For example Debian oldstable still has Qt 5.3.2, and I don't like to drop support for a still supported distribution if not absolutely necessary.

libs/librepcb/common/graphics/graphicsview.cpp Outdated Show resolved Hide resolved
libs/librepcb/common/graphics/graphicsview.cpp Outdated Show resolved Hide resolved
libs/librepcb/common/graphics/graphicsview.cpp Outdated Show resolved Hide resolved
@jeffwheeler

This comment has been minimized.

Copy link
Contributor Author

jeffwheeler commented Jul 5, 2019

Thanks for the feedback, I’ll review in a few days. :)

@rnestler

This comment has been minimized.

Copy link
Member

rnestler commented Jul 5, 2019

For example Debian oldstable still has Qt 5.3.2, and I don't like to drop support for a still supported distribution if not absolutely necessary.

So we could bump the minimal required Qt version from 5.2 to 5.3

@jeffwheeler

This comment has been minimized.

Copy link
Contributor Author

jeffwheeler commented Jul 20, 2019

Hi @ubruhin, I think your comments should now be addressed. Behavior should be unchanged for old versions of Qt.

@ubruhin

This comment has been minimized.

Copy link
Member

ubruhin commented Jul 23, 2019

Thanks! Looks like you no longer use QNativeGestureEvent :)

Do I understand correctly that with this PR "pinch to zoom" works out-of-the-box on a MacBook?

I think there is still a small issue with the implementation: The method grabGesture() is called in setUseOpenGl(), but not in the constructor of GraphicsView. So by default, gestures are not grabbed and thus (probably) gestures won't work. But actually it still works "by accident" because setUseOpenGl() is called by users of GraphicsView anyway. If you want to fix this - perfect. If not - don't worry, I'd still merge this since it's not critical 🙂

@ubruhin ubruhin dismissed their stale review Jul 23, 2019

Issues fixed.

@jeffwheeler

This comment has been minimized.

Copy link
Contributor Author

jeffwheeler commented Jul 24, 2019

Thanks! Looks like you no longer use QNativeGestureEvent :)

Yup. I discovered that QGestureManager::QGestureManager has an #if defined(Q_OS_OSX), and if so, registers the native Mac gesture recognizers (such as QMacPinchGestureRecognizer). Those gesture recognizers will trigger the standard gestures once they receive the native gestures.

Do I understand correctly that with this PR "pinch to zoom" works out-of-the-box on a MacBook?

Yup. 🙂

I think there is still a small issue with the implementation: The method grabGesture() is called in setUseOpenGl(), but not in the constructor of GraphicsView. So by default, gestures are not grabbed and thus (probably) gestures won't work. But actually it still works "by accident" because setUseOpenGl() is called by users of GraphicsView anyway. If you want to fix this - perfect. If not - don't worry, I'd still merge this since it's not critical 🙂

I'll push a fix for this momentarily.

@ubruhin

This comment has been minimized.

Copy link
Member

ubruhin commented Jul 24, 2019

Perfect, thank you very much for this improvement! 😃

@ubruhin ubruhin added this to the 0.1.3 milestone Jul 24, 2019
@ubruhin ubruhin changed the title Native Mac OS gestures GraphicsView: Implement pinch to zoom Jul 24, 2019
@ubruhin ubruhin merged commit b305ba5 into LibrePCB:master Jul 24, 2019
10 checks passed
10 checks passed
LibrePCB Build #20190724.1 succeeded
Details
LibrePCB (Doxygen) Doxygen succeeded
Details
LibrePCB (Linux Ubuntu_1404_GCC) Linux Ubuntu_1404_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1604_GCC) Linux Ubuntu_1604_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1604_Qt_5_12_3_GCC) Linux Ubuntu_1604_Qt_5_12_3_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1804_Clang) Linux Ubuntu_1804_Clang succeeded
Details
LibrePCB (Linux Ubuntu_1904_GCC9) Linux Ubuntu_1904_GCC9 succeeded
Details
LibrePCB (Stylecheck) Stylecheck succeeded
Details
LibrePCB (macOS) macOS succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
ubruhin added a commit that referenced this pull request Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.