aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/pointerhandlers/qquickpinchhandler/tst_qquickpinchhandler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Correct license for test filesLucie Gérard2024-02-271-1/+1
| | | | | | | | | | | | | | According to QUIP-18 [1], all test files should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Normalize signal/slot signaturesMarc Mutz2023-07-121-1/+1
| | | | | | | | | | | | | | This is the result of running util/normalize on the code base. The following manual edits were needed: - skipped the hits in IS_SIGNAL_CONNECTED, which is using function pointers under the hood - restored the space before * in Q_SIGNAL void foo(QType *arg) Pick-to: 6.6 Change-Id: I299b3747c1aa2f6b3bc5ae1794edeb6fadfd75c6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix PinchHandler.persistentTranslation; test cumulative native gesturesShawn Rutledge2023-04-111-7/+31
| | | | | | | | | | | | | | | | | | | | | Since we do not want persistentTranslation to be always the same as target.position, clearly we cannot use xAxis/yAxis to store the initial target position: thus the startPos() function was wrong, and is now removed. We need to store it in a separate m_startTargetPos variable like DragHandler does, and as PinchHandler did before 7867a683fcb938939fb2837a26ac8e1941e3fe08. Add an internal doc comment to clarify the arguments to QQuickItemPrivate::adjustedPosForTransform(). tst_QQuickPinchHandler::cumulativeNativeGestures() now checks the result of adjustedPosForTransform(): how far the target item moved. Pick-to: 6.5 Fixes: QTBUG-111220 Change-Id: I04237cb82a1abaaeab873a0d887acaf322f262ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix and test PinchHandler native-gesture scalingShawn Rutledge2023-02-171-0/+99
| | | | | | | | | | | | We didn't have test coverage for several gesture events in a row (the usual case in reality), nor for RotateNativeGesture at all. Amends a432970b258edb9ff041d221b2155df30cad4799 which incorrectly treated QNativeGestureEvent::value() as an absolute zoom rather than a delta. Pick-to: 6.5 Fixes: QTBUG-111204 Change-Id: Ib95cab5cd3f97229abac1668e59d20ce50d24975 Reviewed-by: Doris Verria <doris.verria@qt.io>
* tst_QQuickPinchHandler: use QScopedPointer for input devicesShawn Rutledge2023-02-171-19/+19
| | | | | | | | Avoid leaking. Same solution as 0879758f8ece9f3b2a799eb87de25813934ba02f Pick-to: 6.5 6.4 6.2 Change-Id: I7e182730757f01c6f93292b594a10681c8fa2cf2 Reviewed-by: Doris Verria <doris.verria@qt.io>
* Improve DragHandler tests for easier troubleshootingShawn Rutledge2023-01-091-0/+6
| | | | | | | | | | | - Sometimes you just need to see the touchpoints and centroids - Delay long enough to see them - Avoid QTRY_COMPARE when we're sure the event was already flushed - Fix indentation Pick-to: 6.5 Change-Id: I307963378c29fb285190657e7a0693888ad7c48c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Stop using deprecated QQuickPinchHandler functions and signalsIvan Solovev2022-12-161-54/+60
| | | | | | | | | Amends a432970b258edb9ff041d221b2155df30cad4799. Task-number: QTBUG-109392 Pick-to: 6.5 Change-Id: I394f2c4b3dc430bbaa2cb55081b6047160ea291b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* PinchHandler: don't confine activeScale and activeRotation to min/maxShawn Rutledge2022-12-121-4/+8
| | | | | | | | | | | | | | | | | | | | | It was inconsistent to do this for the active values only on one handler's axis objects. The main purpose of the minimum and maximum values is to avoid modifying the target item's respective properties beyond reasonable limits, whereas the active values are supposed to be derived directly from the gesture. If the users modify target properties based on active values, or based on the activeValueChanged signal argument, they need to enforce the property limits themselves. [ChangeLog][QtQuick][Event Handlers] PinchHandler's activeScale (which was previously called scale) is no longer restricted to the range between minimumScale and maximumScale: these limits apply only to persistentScale. Likewise, activeRotation (previously rotation) is no longer restricted to the range between minimumRotation and maximumRotation. Change-Id: I5757e3d931e6165c81cecff19fc30b50033d89ce Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Standardize Drag/PinchHandler active/persistent scale, rotation, translationShawn Rutledge2022-12-101-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PinchHandler.scale is persistent between gestures, whereas rotation and translation were active-gesture properties; that wasn't consistent. We fixed up DragHandler in just this way in 6.2. The translationChanged() signal now comes with a vector delta, which is often useful when writing an onTranslationChanged JS handler. Likewise, scaleChanged() and rotationChanged() come with qreal deltas. The scaleChanged() delta is multiplicative rather than additive, because an additive delta would not be useful in cases when some target item's scale can be adjusted by alternative means: you need to multiply it in your onScaleChanged function. Now that PinchHandler has 4 axes as grouped properties, some properties in the handlers themselves begin to look redundant; but at least the translation properties are useful to group x and y together. So in this patch we continue to follow the pattern that was set in 60d11e1f69470d588666b76092cd40ae5644a855. PinchHandler.scale is equivalent to persistentScale, whereas rotation is equivalent to activeRotation; so we have a reason to deprecate those properties, as in ea63ee523377bd11b957a9e74185792edd9b32e8. The persistent values have setters, to provide another way for applications to compensate when the values are adjusted by other means, as an alternative to incremental changes via a script such as rotationAxis.onValueDelta, onRotationChanged etc. [ChangeLog][QtQuick][Event Handlers] PinchHandler.activeTranslation now holds the amount of movement since the pinch gesture began. PinchHandler.persistentTranslation holds the accumulated sum of movement that has occurred during subsequent pinch gestures, and can be set to arbitrary values between gestures. Likewise, activeScale, persistentScale, activeRotation and persistentRotation follow the same pattern. The scaleChanged, rotationChanged, and translationChanged signals include delta arguments, which are useful for incrementally adjusting a non-default item property when the target is null. Fixes: QTBUG-76739 Task-number: QTBUG-94168 Change-Id: I6aaa1aa3356b85e6d27abc64bfa67781ecb4f062 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add PinchHandler.scaleAxis, rotationAxis; hold values in axesShawn Rutledge2022-12-101-45/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pointer Handlers that manipulate target item properties should now use QQuickDragAxis consistently to: - enforce minimum and maximum values - hold the persistent and active values - make those available via properties - emit a new activeValueChanged(delta) signal when the value changes, so that it's possible to incrementally update a target item property in JS (onValueDelta: target.property += delta) In the pinchHandler.qml example, you can use the PinchHandler to adjust 4 properties of one Rectangle independently (it requires coordination). m_boundedActiveValue controls whether m_activeValue will be kept between minimum and maximum. For rotation, tst_QQuickPinchHandler::scaleNativeGesture() expects it to be, although that seems questionable now, and may be addressed later. [ChangeLog][QtQuick][Event Handlers] PinchHandler now has scaleAxis and rotationAxis grouped properties, alongside the existing xAxis and yAxis; and all of these now have activeValue and persistentValue properties. The activeValueChanged signal includes a delta value, giving the incremental change since the previous activeValue. The persistentValue is settable, in case some target item property can be adjusted in multiple ways: the handler's stored value can then be synced up with the item property value after each external change. These features are also added to DragHandler's xAxis and yAxis properties. Task-number: QTBUG-68108 Task-number: QTBUG-76380 Task-number: QTBUG-76379 Task-number: QTBUG-94168 Change-Id: I78a5b43e9ba580448ef05054b6c4bc71b1834dd6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add qCDebug to tst_QQuickPinchHandler::scaleThreeFingersShawn Rutledge2022-11-261-0/+1
| | | | | | | When it fails locally, I want to see the actual scale value. Change-Id: Iecdf1dc2bb9660d3f6d11dea57fb2ca5aafd0068 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler null target: remember accumulated scale between pinchesShawn Rutledge2022-11-171-3/+48
| | | | | | | | | | | | | | | | | | | | This restores behavior from b4d31c9ff5f0c5821ea127c663532d9fc2cae43e which got broken in fc636af3a723ee8b4ee42cf71864ae0df5ca4621. As documented, PinchHandler.scale is the accumulated scale that would be applied to the target item (even if there is no target), whereas activeScale is the scale during one pinch gesture. After the first gesture, these two values are supposed to diverge, even if there is no target; that way you can bind scale to some property, to scale something else in the same way that PinchHandler would normally scale its target. Pick-to: 6.2 6.4 Fixes: QTBUG-108549 Task-number: QTBUG-68941 Task-number: QTBUG-92064 Change-Id: I32ff37e394fd8466128603eddd5697ba1cc1a0ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Make tst_QQuickPinchHandler::scale easier to maintainShawn Rutledge2022-11-171-73/+58
| | | | | | | | | | | | | | | | | | | | | | | | I kept forgetting why there were odd indented blocks, why it was letting the QTouchEventSequence go out of scope and making a new one, and why that resulted in an out-of-bounds pinch. It works well enough to just drag the second touchpoint all the way down into the lower-right corner: without maximumScale being set, it goes to 5.75, so we can verify that setting maximumScale limits it to 4. While we're at it: - use QQuickTest::showView() - better comments - loop instead of copy-pasting blocks of code - show the touchpoints - slow it down enough to see them when cat. logging is turned on - get rid of that weird opacity hack - check pinchHandler's own scale() and activeScale() properties Amends f289141524d9331bdafd9f88d95e0fa9b29ccdee Pick-to: 6.2 6.4 Change-Id: I799c256286f4408f89c0502db33c9f676a2ce1b1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_qquickpinchhandler: rename root.scale property to pinchScaleShawn Rutledge2022-11-171-10/+10
| | | | | | | | | | | | It doesn't look sensible to hide the existing Item.scale property. PinchArea's properties are directly accessible in test code, but maybe there's some sense in testing the onActiveChanged and onUpdated signals. Amends f289141524d9331bdafd9f88d95e0fa9b29ccdee which copied code from tst_qquickpincharea. Pick-to: 6.2 6.4 Change-Id: I108fffc9b99b4eebc949fe11c9b7dd649d98f59a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_QQuickPinchHandler::scaleThreeFingers: stop using root propertiesShawn Rutledge2022-11-171-5/+6
| | | | | | | | | | It's confusing to hide root's Item.scale property with another property; and the others aren't needed either. Use the PinchHandler properties directly. Amends f289141524d9331bdafd9f88d95e0fa9b29ccdee which copied code from tst_qquickpincharea (which still has the same silliness). Change-Id: Ib30fd81314f14c235948179462cd4a2dd742a65d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-12/+12
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* PinchHandler: Enforce min/max scale limits with native gesturesShawn Rutledge2022-09-011-18/+25
| | | | | | | | | | | So far the qBound() using m_minimumScale and m_maximumScale was only applied for normal pointer events: there were no limits when using a touchpad that sends native gestures. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106110 Change-Id: Ibf8d955e5f1dac517e0a3e9588fb117d83f443a6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Don't rely on transitive include of qeventpoint_p.hMarc Mutz2022-01-131-1/+1
| | | | | | | | | | It will be dropped from qevent_p.h. Task-number: QTBUG-99615 Pick-to: 6.3 6.2 Change-Id: Id4eee3036a873f0e021b30a8d43b2c4df25dc53c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* tests: port to QMutableEventPoint static APIMarc Mutz2022-01-131-5/+5
| | | | | | | | | | | | This code was actually ok (no UB), but it's in the way of making QMutableEventPoint a befriendable namespace, so port from using QMutableEventPoint to QEventPoint instances + QMutableEventPoint static setters. Task-number: QTBUG-99615 Pickt-to: 6.3 Change-Id: I7ddcf154cb5da9b6ea2f0f0d8cac130a28203371 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-21/+12
| | | | | | | | | | | | | | | | | | | | Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Update sceneGrabPosition in MultiPointHandler's points, on grabShawn Rutledge2021-06-021-1/+12
| | | | | | | | | | We seem to have gotten by without this somehow; but the debug output in QQuickPinchHandler::handlePointerEventImpl() made it clear that it wasn't being done: it would always say the points moved from 0,0 to their present locations. Change-Id: If611adea6ecf0c056ae7d9b34ca86a7530cfc144 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Emit grabChanged() from DragHandler and PinchHandlerShawn Rutledge2021-05-271-0/+4
| | | | | | | | | | | Followup to ca7cdd71ee33f0d77eb6bf1367d2532e26155cb2 : when overriding a virtual function, it's good practice to call the base class function, in the absence of any reason not to. Pick-to: 5.15 6.1 Fixes: QTBUG-93880 Change-Id: Icbd04faec51d55d8fbf73319bd20f5846761d3d5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* DragHandler: don't try to handle native gesture eventsShawn Rutledge2021-03-261-20/+32
| | | | | | | | | | | | | | | | | | No gesture handling has been implemented in DragHandler (although we could). It just made the target item jump unintentionally. QQuickMultiPointHandler::wantsPointerEvent() returns true for gestures, because PinchHandler handles them, and the pattern is that base classes only rule out some kinds of events but leave the final decision up to the leaf class. The autotest has to use a touchpad now, not the primary pointing device, because QQuickPointerDeviceHandler::wantsPointerEvent() returns false if pointerType != Finger and acceptedButtons() is not satisfied. Fixes: QTBUG-92165 Change-Id: I984de750c9ae892f3ee61c7ed5b3ac4a7d187024 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* PinchHandler: scale incrementally when new pinch gesture beginsShawn Rutledge2021-03-251-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | When the gesture begins, we begin multiplying the target item's scale by 1.0 at first; it doesn't make sense to start immediately with the accumulated scale remembered from previous pinch gestures, because the target item remembers its own scale. When QQuickPinchHandler::wantsPointerEvent() returns false because some irrelevant gesture was received (for example a PanNativeGesture), that's not a good reason to deactivate. Deactivating and re-activating with each ZoomNativeGesture event results in extreme behavior, because PinchHandler depends on the BeginNativeGesture and EndNativeGesture events to reset internal state. Likewise, the fact that the button state is NoButton is not a good reason for wantsPointerEvent() to return false. Added an autotest: the first of its kind that actually simulates the native gesture events. Fixes: QTBUG-92064 Pick-to: 5.15 6.0 6.1 Change-Id: I3a9b92d70f99497ee58ad8557d90d521fbe16d41 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Begin handling the QEvent refactoringShawn Rutledge2020-07-151-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an intermediate step to get Qt Quick working again after qtbase 4e400369c08db251cd489fec1229398c224d02b4. - QQuickEventPoint::id() is no longer unique across devices, because now eventPoint.event.device tells which specific device the event comes from. (In Qt 5, we could not yet add the device pointer to QInputEvent.) - However, MultiPointTouchArea's docs say that each pointId is unique, and so do the HandlerPoint docs (for similar use cases with PointHandler). So we still need the same hack using a Qt-specific short device ID to unique-ify the QEventPoint::id(). Now we use the device index in QInputDevice::devices() as the short ID. - Otherwise, we trust QInputDevice::systemId() and QEventPoint::id() more than before. - Use QMutable* classes from qevent_p.h to continue using setters that were in QTouchEvent before, etc. But setTouchPoints() is not there, so we have to make new event instances in a couple of cases. - QGuiApplicationPrivate::setMouseEventCapsAndVelocity() and setMouseEventSource() are gone. - Use (compiler-written) event copy constructors when possible. Task-number: QTBUG-72173 Change-Id: I3915dc535ae4c5a81cbf333aba9355f01c420c15 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace QTouchEvent::TouchPoint with QEventPointShawn Rutledge2020-07-151-2/+2
| | | | | | | | | | | | It's a cosmetic change at this time, because we have declared using TouchPoint = QEventPoint; Also replace Qt::TouchPointState enum with QEventPoint::State. Task-number: QTBUG-72173 Change-Id: Ife017aa98801c28abc6cccd106f47a95421549de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove QQuickPointerDevice in favor of QPointingDeviceShawn Rutledge2020-06-231-14/+3
| | | | | | | | | | | | | | ...and generally deal with changes immediately required after adding QInputDevice and QPointingDevice. Also fixed a few usages of deprecated accessors that weren't taken care of in 212c2bffbb041aee0e3c9a7f0551ef151ed2d3ad. Task-number: QTBUG-46412 Task-number: QTBUG-69433 Task-number: QTBUG-72167 Change-Id: I93a2643162878afa216556f10808fd92e0b20071 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: Avoid unwanted translations when axes are disabledShawn Rutledge2019-01-281-0/+80
| | | | | | Fixes: QTBUG-72822 Change-Id: I2773ba14fcb24a47fe2ec04860b4aa305a051453 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add a C++ autotest for PinchHandlerShawn Rutledge2018-08-021-0/+692
Adapted from the PinchArea test. cancel() does not work, TDB if we want to support that Done-with: Jan-Arve Sæther <jan-arve.saether@qt.io> Task-number: QTBUG-69134 Change-Id: I63dfba7b327220b9f032f19c588cc19ebdfd95c2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>