aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpinchhandler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.12.1' into 5.12Liang Qi2019-02-011-19/+37
|\ | | | | | | | | | | | | Conflicts: src/quick/handlers/qquickpinchhandler.cpp Change-Id: I1f3618ceb93049623d6bf3a208b037c33d9d1f0c
| * Fix axis constraints API and documentation:v5.12.1Jan Arve Sæther2019-01-211-19/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should have been done properly for 5.12. Since this API was introduced in 5.12.0, we simply hide the documentation for the old properties and make sure the properties we want to expose are documented: * Document the xAxis and yAxis properties. * Deprecate the {min,max}imum{X,Y} properties, and hide them in the documentation. Fixes: QTBUG-73137 Change-Id: Ic749bcfec63dc4772f193ccae2a2750c20cb63aa Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | PinchHandler: fix pedantic warningsShawn Rutledge2019-01-281-18/+18
| | | | | | | | | | | | | | | | | | - qreal<->float conversions are explicit - use qFuzzyCompare rather than == - remove padding between variables (but the class still needs padding) Change-Id: I9a9eb01f5a4108592b34e4b2f018c720ba19beb0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* | PinchHandler: Avoid unwanted translations when axes are disabledShawn Rutledge2019-01-281-6/+4
|/ | | | | | Fixes: QTBUG-72822 Change-Id: I2773ba14fcb24a47fe2ec04860b4aa305a051453 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: update centroid property when handling native gestureShawn Rutledge2018-09-131-0/+1
| | | | | | | | | | The gesture occurs at a location. It so happens that when the gesture begins, macOS holds the position fixed; but on other OSes, maybe the position could move around, if dragging during pinch is allowed. Change-Id: Ie3184b5002548cb8fff3b3b6c471966ae4b8f6d9 Fixes: QTBUG-70075 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Doc: Fix the QML type of MultiPointHandler.centroidShawn Rutledge2018-09-111-1/+1
| | | | | | | | We use QML types not C++ types in QML docs. This fixes links so that you can see the centroid's properties. Change-Id: I3efe04dbfefba965176030adc3e65672519b81dc Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Remove the PinchHandler.pinchOrigin property for nowShawn Rutledge2018-08-311-26/+1
| | | | | | | | | We didn't get around to implementing the appropriate behaviors. We could add it back later if we figure out how. Task-number: QTBUG-70292 Change-Id: Idca62b249f555d5e44bb97430ae0222bf314a66b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Doc: clarify the type and meaning of QQuickMultiPointHandler::centroidShawn Rutledge2018-08-221-1/+1
| | | | | | | | | | | | Amends 52d35526f256bf4c8155f5e660a214ab8a2efbdf : it's now a QQuickHandlerPoint rather than QPointF, and is inherited from MultiPointHandler to DragHandler and PinchHandler. So the docs can be inherited too, but in PinchHandler it seems more appropriate to keep the overridden docs which explain that transformation around the centroid depends on pinchOrigin. Task-number: QTBUG-70074 Change-Id: I8875b38439fe80c311a685ab9e3dedc9357415e8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Let axis bounds restrict the target position instead of the centroidJan Arve Sæther2018-08-021-7/+6
| | | | | Change-Id: I09442cfd5ea1e3bee06dd448118f2f42bedb2760 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make pinch handler not activate on draggingJan Arve Sæther2018-08-021-5/+98
| | | | | | | | | | | | | | ..when dragging (translation) is disabled In order to do this, we had to integrate QQuickAxis to the PinchHandler which allows enabling/disabling x and y axis individually. This allows us to have one item with PinchHandler with translation disabled (but to only handle rotate and scale) together with a two-finger drag handler. Change-Id: I1581c575ffba2e5d007163bec36e5699bdd86cbc Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix PointerHandler constructors and destructorsShawn Rutledge2018-07-271-20/+1
| | | | | | | | | | | | | - Constructors should take QQuickItem* not QObject* to be symmetric with the parentItem() accessor (and other code) which assumes its type - Use header initialization everywhere possible - Reorder variables to minimize padding (somewhat) - Remove empty destructor bodies (the compiler can write them) - Remove override and virtual from destructors in accordance with https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override Change-Id: I682a53a803d65e29136bfaec3a5b534e975ecf30 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Rearrange docs: Pointer Handlers -> Input HandlersShawn Rutledge2018-07-261-2/+2
| | | | | | | | | | | | | | | At QtCS 2018 we decided to rename Pointer Handlers to Input Handlers and include the Keys attached property as part of this set (since we plan to have attached-property pointer handlers too, eventually). It's no longer a module, it's included in Qt Quick 2.12. We need to start promoting Input Handlers and reducing the visibility of legacy stuff like MouseArea and MultiPointTouchArea (in the hope of being able to deprecate them eventually). Task-number: QTBUG-66651 Change-Id: I801351ac2531191cbb1faac9318441c67a109af6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QQuickMultiPointHandler: store QQuickHandlerPoints, not QQEventPoint*sShawn Rutledge2018-07-191-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QQuickPointerTouchEvent::reset(QEvent *event) reuses instances of QQuickEventPoint from one touch event to the next, but it makes no attempt to match up each instance with the same pointId from the event. So from the perspective of Handlers, each event can have its touchpoints in a different order, and therefore it's always wrong to hold onto any QQuickEventPoint pointer between events. Instead we use QQuickHandlerPoint for storage: both for exposing to QML, and for internal storage in handlers that need to remember touchpoint state. Without this change, any MultiPointHandler could "forget" which point IDs it had chosen to react to, in any case where the event contains additional points. It was using a QVector<QQuickEventPoint *> to remember the chosen points, but each of those instances might be assigned a different touchpoint during the handling of the next touch event (and thus its ID would change "underneath"). Perhaps this went unnoticed until now because 1) the only subclass of MultiPointHandler was PinchHandler, and we didn't often test use cases with extra touchpoints beyond the ones involved in the pinch and 2) on Linux/X11 they stayed in the same order in each event. But as soon as we try to make DragHandler inherit MultiPointHandler, it becomes clear that it does not succeed in holding on to a particular touchpoint while dragging multiple DragHandlers with multiple fingers, without this patch. Change-Id: If7e0daa9ed77b263efc09f5ea73dfba6a3c8205c Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Rename Pointer Handlers to Input Handlers (as a concept)Shawn Rutledge2018-07-121-1/+1
| | | | | | | | | | | | | | | | This is a documentation change to alleviate some confusion that we've seen during the Tech Preview period. It doesn't make sense to actually rename the base class though, because it is intended to handle QQuickPointerEvents, not QEvents. The reason for that is that refactoring the QEvent hierarchy has to wait until Qt 6. So maybe in Qt 6 we can remove QQuickPointerEvent and have a QQuickInputHandler base class which handles QInputEvents; but for now, this conceptual renaming seems about as far as we can go. Task-number: QTBUG-66651 Change-Id: I84a41dc282c480d08f4d4a0d9a857e37e074aa7a Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* PinchHandler: rename scale to activeScale; scale means target scaleShawn Rutledge2018-06-271-9/+22
| | | | | | | | | | | | If you want to set target: null and then bind scale to some sort of rendering scale property directly, it's a lot less trouble if the scale property does not keep changing back to 1.0 every time a gesture begins. Added an activeScale property to represent that value, the one that the scale property had before. Task-number: QTBUG-68941 Change-Id: Idcb6735d915a523afe1a948609080af7a83f82ad Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devUlf Hermann2018-06-251-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/quick/handlers/qquickhandlerpoint.cpp src/quick/handlers/qquicksinglepointhandler.cpp tests/auto/qml/ecmascripttests/test262 Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
| * Doc: Add missing dots (qtdeclarative)Paul Wicking2018-06-191-1/+1
| | | | | | | | | | | | Task-number: QTBUG-68933 Change-Id: Ibb5aa227e82825085e7214e17dcffcb17fd44157 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | MultiPointHandler: add a centroid propertyShawn Rutledge2018-05-181-26/+11
|/ | | | | | | | | | | | | | | One of the reasons we were so fond of using SinglePointHandler for the "simple" handlers like TapHandler and DragHandler is that it has the point property, which is easy to bind to in QML. But multi-point handlers tend to use the centroid as the focal point or fulcrum of the transformation, so exposing the centroid as a QQuickHandlerPoint gadget rather than just a QPointF has all the same advantages as the point property in SinglePointHandler, including letting the QQuickHandlerPoint instance store state between events (press position, grab position, last known position etc.) Change-Id: I4a955fa21b54b7ebb50b0ee2c942fb98eeccb560 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix build without features.gesturesTasuku Suzuki2018-05-141-1/+6
| | | | | | Change-Id: Id2fb6419be9a35ddaa24106d3022e72070cb908d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* fix bugs in native gesture event deliveryShawn Rutledge2017-12-111-2/+4
| | | | | | | | | | | 1) always use Item-localized coordinates when testing Item.contains() 2) QQuickPinchHandler::wantsPointerEvent() was returning true for all native gestures, so in the manual test with two PinchHandlers, it was possible to pinch them both at the same time. Task-number: QTBUG-64848 Change-Id: Ia146aaf03f9982696ae2986249f8d4650a7bf727 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Let passive-grabbing PointerHandlers see all point updatesShawn Rutledge2017-11-141-4/+9
| | | | | | | | | | | even if all points are accepted or grabbed. A passive grab isn't much good if there are cases where the handler is prevented from monitoring. This enables e.g. the PinchHandler to steal the grab when the right number of touchpoints are present and have moved past the drag threshold, and enables completion of a couple of autotests. Change-Id: I78dc6fc585f80bfb3c13e0c6e757ef815fb94afe Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: add native pinch gesture supportShawn Rutledge2017-09-291-31/+89
| | | | | | | | | macOS generates QNativeGestureEvents for 2-finger trackpad zoom and rotation gestures. Now PinchHandler will react to them in the same way that PinchArea does. Change-Id: I4c7dab1d3561d20897e3671f4eb68d01ea06b9bd Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* improve documentation of PinchHandlerShawn Rutledge2017-09-291-0/+48
| | | | | | | The readonly properties were omitted until now. Change-Id: Ia4f4b8ff5a390f6e802008c9c636d7d8ab2a3278 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* improve documentation of PinchHandlerShawn Rutledge2017-09-141-12/+75
| | | | | | Change-Id: If7acf359731a046637248d9b415b9e865365a068 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: correct the usage of min/max x/y for movement boundsShawn Rutledge2017-09-121-1/+1
| | | | | | | QRectF constructor takes x, y, width, height not x1, y1, x2, y2 Change-Id: I84f9e62ef7a6587a319ed33d8937365f94fdba3b Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: make the properties useful when target is nullShawn Rutledge2017-09-121-15/+18
| | | | | | | | | | An example is forthcoming in the form of a documentation snippet. Also, translation is a relative measurement, so its type is now QVector2D rather than QPointF. This doesn't change the QML API: x and y properties are still defined. Change-Id: I00f9a02a45c30899a568fe827f47cae9b4cc0f42 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* rename QQuickEventPoint pos properties to positionShawn Rutledge2017-09-051-1/+1
| | | | | | | | For consistency we always spell it out, although it does make some of these properties inconveniently verbose. Change-Id: I64a08c3aa261c0ab89e09472dd47510abafbf7ca Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Rename single and multi pointer handler classnamesJan Arve Sæther2017-09-031-1/+1
| | | | | | | | | Renames: QQuickPointerSingleHandler -> QQuickSinglePointHandler QQuickMultiPointerHandler -> QQuickMultiPointHandler Change-Id: I10c54944f85ca7cac374ebc6241d61793e2d38bf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix some qdoc warnings for 5.10Friedemann Kleint2017-08-281-4/+4
| | | | | | | | | | | | | | | | | | | qtdeclarative/src/imports/shapes/qquickshape.cpp:577: warning: Command '\li' outside of '\list' and '\table' qtdeclarative/src/imports/shapes/qquickshape.cpp:585: warning: Command '\li' outside of '\list' and '\table' qtdeclarative/src/imports/shapes/qquickshape.cpp:592: warning: Command '\li' outside of '\list' and '\table' qtdeclarative/src/imports/shapes/qquickshape.cpp:596: warning: Command '\li' outside of '\list' and '\table' qtdeclarative/src/imports/shapes/qquickshape.cpp:602: warning: Command '\li' outside of '\list' and '\table' qtdeclarative/src/imports/shapes/qquickshape.cpp:608: warning: Unexpected '\endlist' qtdeclarative/src/quick/handlers/qquickpinchhandler.cpp:138: warning: Missing property type for QQuickPinchHandler::minimumX qtdeclarative/src/quick/handlers/qquickpinchhandler.cpp:151: warning: Missing property type for QQuickPinchHandler::maximumX qtdeclarative/src/quick/handlers/qquickpinchhandler.cpp:164: warning: Missing property type for QQuickPinchHandler::minimumY qtdeclarative/src/quick/handlers/qquickpinchhandler.cpp:177: warning: Missing property type for QQuickPinchHandler::maximumY qtdeclarative/src/quick/items/qquickitem.cpp:7241: warning: No such parameter 'enabled' in QQuickItem::setAcceptTouchEvents() qtdeclarative/src/quick/items/qquickitem.cpp:7241: warning: Undocumented parameter 'accept' in QQuickItem::setAcceptTouchEvents() qtdeclarative/src/quick/items/qquickwindow.cpp:4829: warning: No such parameter 'backend' in QQuickWindow::sceneGraphBackend() Change-Id: Iec2ced892e068317c60517cedacc27e8c82b26b3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Start over with event delivery when touchpoint releases occurShawn Rutledge2017-05-221-2/+4
| | | | | | | | | | | | | | | | | | | | The new rule is that when the number of touchpoints changes, we start over with event delivery as if the touch had just begun, to give more opportunities to hand off processing from one item or handler to another. And MultiPointTouchArea can now handle the handoff: for example in tests/manual/pointer/pinchDragFlingMPTA.qml when the user is pressing three fingers, the PinchHandler is active; when the user then lifts one finger, the MPTA can resume handling the two remaining touchpoints as if they were just pressed. The change in QQuickMultiPointerHandler::wantsPointerEvent is both a behavior change and an optimization: released points aren't eligible; but if some points are released, then pressed, updated and stationary points are all eligible. And, figure this out without looping over the points twice. Change-Id: I26b7593de8e72b471adfec4a4482dd87a8288442 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQMultiPointerHandler: don't steal grab if keepMouseGrab/keepTouchGrabShawn Rutledge2017-04-271-2/+2
| | | | | | | | | | An Item (such as MPTA with onGestureStarted: gesture.grab()) may set these flags, traditionally to prevent Flickable from stealing the grab. QQuickMultiPointerHandler (and thus PinchHandler) now respects these flags too. Change-Id: Iac3ab796c5aa410be45639d679ecf82b7c44a442 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: add centroidVelocityShawn Rutledge2017-04-201-0/+1
| | | | | Change-Id: I34cc9146155bded8311c1173e4b8d34d8b17b034 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: Do not grab immediatelyJan Arve Saether2017-03-141-6/+12
| | | | | | | | Do not grab until at least one of the points have moved beyond the drag threshold Change-Id: I30de6332cc8e2b0238cacf5c4f0f70efbdc4d41d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* DragHandler active property replaces dragging; same as grabbingShawn Rutledge2016-12-291-0/+4
| | | | | | | | | | | | | | | | | If a QQuickPointerSingleHandler grabs a point, it's definitely in the active state: doing something with the point. (The converse is not always true though: e.g. TapHandler can sometimes detect a tap without ever grabbing.) In DragHandler, the "dragging" property means the same as "active": we always grab when dragging, to be sure to get the updates. So the "dragging" property is removed because it's redundant. In QQuickPointerHandler we don't say that "wanting" an event is the same as being active, because 1) it won't necessarily grab right away and 2) every handler which was active should "want" the release event, yet it needs to setActive(false) as soon as it's done processing it. Change-Id: Ie010db54714a7914109da6469e79865f9a0a18e4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Let pinchhandler operate on QQuickItem propertiesJan Arve Saether2016-12-271-47/+54
| | | | | | | | | | | | | | | | | | | | | | | | This requires coordinate system mapping that varies with the transformOrigin. The properties exposed from PinchHandler (rotation, scale and translation) are currently relative to the point when the pinch became active. (Therefore, rotation, will reset back to 0 when a new pinch is activated). Its still unclear how the properties that limits the transform should influence. With this patch, they are like this: * {min,max}imumRotation applies to the actual rotation of the item. * {min,max}imumScale applies to the actual scale of the item. * {min,max}imum{X,Y} applies to the actual position of the item. (This has some unfortunate side-effects when the item is scaled or rotated, since the items actual position will change as it rotates) In addition, the behavior described above means that the limits won't have any effect if there is no target item. Change-Id: I279fb03667cd75324e8337039ae2594658265d13 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* add virtual QQuickPointerHandler::onActiveChangedShawn Rutledge2016-12-091-1/+0
| | | | | | | | | | | | | and override it in PinchHandler. Many handlers will need to do something in response to change in active state, so calling a virtual when the state changes and overriding it in subclasses is more efficient than for subclasses to connect to the activeChanged signal. This also helps us control the signal emit order: the subclass can deal with any consequences (such as changing its own properties) before activeChanged is emitted. Change-Id: I6d05643e8facfd1941aa9152de6865932edb1b3a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: accept all points involved in the pinchShawn Rutledge2016-11-241-0/+1
| | | | | | | | | This is one part of preventing sibling handlers (such as DragHandler) from stealing the grab: mark the points accepted so that allPointsAccepted() will be true, so that delivery stops. Change-Id: Icb650599254dccd949de90b4b7fc44969f6a7c62 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: populate the translation propertyShawn Rutledge2016-11-221-0/+1
| | | | | | | | | It's intended to be total translation of the target item relative to its declared position, independent of scale. Change-Id: I2b8f1bd62ba34c0200ea88b3461a45e1dcf61166 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fixed some problems with the centroid in PinchHandlerJan Arve Saether2016-11-201-28/+39
| | | | | | | | | | | | The centroid was not always mapped to the correct coordinate system In addition, the return value of startingCentroid() was not always desirable, because its implementation calls sceneGrabPos(). We therefore had to get the starting centroid by querying touchPointCentroid() whenever the handler became active. Change-Id: I69de6b832b9bda208fda4eb90a8a95cc975405c2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix rotation in PinchHandlerJan Arve Saether2016-09-161-25/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we want to allow rotation with more than 2 fingers, its not straightforward to calculate the rotation angle, because we cannot anymore calculate the angle between the two touchpoints. The approach chosen was to calculate the angle between the centroid and the touchpoints, and take the average between the angles. Then, for the next event we calculated the new average of the angles. However, this is not really reliable in some scenarios, suppose we have these three angles: 0 120 240, avg = 360/3 = 120 next, touch points rotate clockwise with 2 degrees, and we get these angles: 358 118 238, avg = 714/3 = 238 So, just by rotating all fingers by 2 degrees, we got a jump by 118 degrees "in average". Instead we need to track the angles of *all* touch points, and when the next touch event is received we calculate how much the angle has changed per touch point. We then take the average of those angles as the effective "rotation" of the PinchHandler Change-Id: I2bfdf80b886751177efe81bcc7b698af0d2938e3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Introduce PinchHandlerShawn Rutledge2016-09-011-0/+201
Similar to PinchArea but with improvements: - Allows rotating and scaling about an arbitrary point rather than the center - It's possible to require more than 2 fingers. E.g. maybe you use 3 fingers to manage a window, 2 fingers to manipulate content inside. This could be achieved with two independent PinchHandlers. Change-Id: Ifd40cfee115d7bc298378b26a58318bea40a8230 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>