aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpinchhandler_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.12.1' into 5.12Liang Qi2019-02-011-8/+14
|\ | | | | | | | | | | | | Conflicts: src/quick/handlers/qquickpinchhandler.cpp Change-Id: I1f3618ceb93049623d6bf3a208b037c33d9d1f0c
| * Fix axis constraints API and documentation:v5.12.1Jan Arve Sæther2019-01-211-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+1
|/ | | | | | | | | - 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>
* Remove dubious API features and clutter from Pointer Handler headersShawn Rutledge2018-08-311-2/+0
| | | | | Change-Id: Ica67409f3138828d8a33fef2d67ad799a5a063f5 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Remove the PinchHandler.pinchOrigin property for nowShawn Rutledge2018-08-311-12/+0
| | | | | | | | | 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>
* Make pinch handler not activate on draggingJan Arve Sæther2018-08-021-0/+10
| | | | | | | | | | | | | | ..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-18/+17
| | | | | | | | | | | | | - 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>
* PinchHandler: rename scale to activeScale; scale means target scaleShawn Rutledge2018-06-271-1/+4
| | | | | | | | | | | | 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>
* MultiPointHandler: add a centroid propertyShawn Rutledge2018-05-181-8/+0
| | | | | | | | | | | | | | | 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>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* PinchHandler: add native pinch gesture supportShawn Rutledge2017-09-291-0/+1
| | | | | | | | | 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>
* remove QQuickPinchHandler::requiredPointCountChanged signalShawn Rutledge2017-09-291-1/+0
| | | | | | | This is in QQuickMultiPointHandler Change-Id: Ia4ebb1731395733e2f76edd667330fa15de6f015 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* PinchHandler: make the properties useful when target is nullShawn Rutledge2017-09-121-3/+3
| | | | | | | | | | 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 single and multi pointer handler classnamesJan Arve Sæther2017-09-031-2/+2
| | | | | | | | | Renames: QQuickPointerSingleHandler -> QQuickSinglePointHandler QQuickMultiPointerHandler -> QQuickMultiPointHandler Change-Id: I10c54944f85ca7cac374ebc6241d61793e2d38bf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* PinchHandler: add centroidVelocityShawn Rutledge2017-04-201-0/+3
| | | | | Change-Id: I34cc9146155bded8311c1173e4b8d34d8b17b034 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make all handler constructors explicitJan Arve Saether2017-02-211-1/+1
| | | | | Change-Id: I17b3865d70bdc07912d7454b459dea40b9c98df0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Let pinchhandler operate on QQuickItem propertiesJan Arve Saether2016-12-271-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | 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>
* Fixed some problems with the centroid in PinchHandlerJan Arve Saether2016-11-201-0/+2
| | | | | | | | | | | | 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-8/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+131
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>