OpenCoverage

qquickpinchhandler.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/handlers/qquickpinchhandler.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickpinchhandler_p.h"-
41#include <QtQuick/qquickwindow.h>-
42#include <private/qsgadaptationlayer_p.h>-
43#include <private/qquickitem_p.h>-
44#include <private/qguiapplication_p.h>-
45#include <private/qquickwindow_p.h>-
46#include <QEvent>-
47#include <QMouseEvent>-
48#include <QDebug>-
49#include <qpa/qplatformnativeinterface.h>-
50-
51QT_BEGIN_NAMESPACE-
52-
53Q_LOGGING_CATEGORY(lcPinchHandler, "qt.quick.handler.pinch")
executed 76 times by 1 test: return category;
Executed by:
  • tst_multipointtoucharea_interop
76
54-
55/*!-
56 \qmltype PinchHandler-
57 \instantiates QQuickPinchHandler-
58 \inherits MultiPointHandler-
59 \inqmlmodule Qt.labs.handlers-
60 \ingroup qtquick-handlers-
61 \brief Handler for pinch gestures.-
62-
63 PinchHandler is a handler that interprets a multi-finger gesture to-
64 interactively rotate, zoom, and drag an Item. Like other Pointer Handlers,-
65 by default it is fully functional, and manipulates its \l target,-
66 which is the Item within which it is declared.-
67-
68 \snippet pointerHandlers/pinchHandler.qml 0-
69-
70 It has properties to restrict the range of dragging, rotation, and zoom.-
71-
72 If it is declared within one Item but is assigned a different \l target, it-
73 handles events within the bounds of the outer Item but manipulates the-
74 \c target Item instead:-
75-
76 \snippet pointerHandlers/pinchHandlerDifferentTarget.qml 0-
77-
78 A third way to use it is to set \l target to \c null and react to property-
79 changes in some other way:-
80-
81 \snippet pointerHandlers/pinchHandlerNullTarget.qml 0-
82-
83 \image touchpoints-pinchhandler.png-
84-
85 \sa PinchArea-
86*/-
87-
88QQuickPinchHandler::QQuickPinchHandler(QObject *parent)-
89 : QQuickMultiPointHandler(parent, 2)-
90 , m_activeScale(1)-
91 , m_accumulatedScale(1)-
92 , m_activeRotation(0)-
93 , m_activeTranslation(0,0)-
94 , m_minimumScale(-qInf())-
95 , m_maximumScale(qInf())-
96 , m_minimumRotation(-qInf())-
97 , m_maximumRotation(qInf())-
98 , m_minimumX(-qInf())-
99 , m_maximumX(qInf())-
100 , m_minimumY(-qInf())-
101 , m_maximumY(qInf())-
102 , m_pinchOrigin(PinchCenter)-
103 , m_startScale(1)-
104 , m_startRotation(0)-
105{-
106}
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
107-
108QQuickPinchHandler::~QQuickPinchHandler()-
109{-
110}-
111-
112/*!-
113 \qmlproperty real QtQuick::PinchHandler::minimumScale-
114-
115 The minimum acceptable \l {Item::scale}{scale} to be applied-
116 to the \l target.-
117*/-
118void QQuickPinchHandler::setMinimumScale(qreal minimumScale)-
119{-
120 if (m_minimumScale == minimumScale)
m_minimumScale == minimumScaleDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-4
121 return;
never executed: return;
0
122-
123 m_minimumScale = minimumScale;-
124 emit minimumScaleChanged();-
125}
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
126-
127/*!-
128 \qmlproperty real QtQuick::PinchHandler::maximumScale-
129-
130 The maximum acceptable \l {Item::scale}{scale} to be applied-
131 to the \l target.-
132*/-
133void QQuickPinchHandler::setMaximumScale(qreal maximumScale)-
134{-
135 if (m_maximumScale == maximumScale)
m_maximumScale == maximumScaleDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-4
136 return;
never executed: return;
0
137-
138 m_maximumScale = maximumScale;-
139 emit maximumScaleChanged();-
140}
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
141-
142/*!-
143 \qmlproperty real QtQuick::PinchHandler::minimumRotation-
144-
145 The minimum acceptable \l {Item::rotation}{rotation} to be applied-
146 to the \l target.-
147*/-
148void QQuickPinchHandler::setMinimumRotation(qreal minimumRotation)-
149{-
150 if (m_minimumRotation == minimumRotation)
m_minimumRotat...inimumRotationDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 return;
never executed: return;
0
152-
153 m_minimumRotation = minimumRotation;-
154 emit minimumRotationChanged();-
155}
never executed: end of block
0
156-
157/*!-
158 \qmlproperty real QtQuick::PinchHandler::maximumRotation-
159-
160 The maximum acceptable \l {Item::rotation}{rotation} to be applied-
161 to the \l target.-
162*/-
163void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation)-
164{-
165 if (m_maximumRotation == maximumRotation)
m_maximumRotat...aximumRotationDescription
TRUEnever evaluated
FALSEnever evaluated
0
166 return;
never executed: return;
0
167-
168 m_maximumRotation = maximumRotation;-
169 emit maximumRotationChanged();-
170}
never executed: end of block
0
171-
172/*!-
173 \qmlproperty real QtQuick::PinchHandler::pinchOrigin-
174-
175 The point to be held in place, around which the \l target is scaled and-
176 rotated.-
177-
178 \value FirstPoint-
179 the first touch point, wherever the first finger is pressed-
180 \value PinchCenter-
181 the centroid between all the touch points at the time when the-
182 PinchHandler becomes \l active-
183 \value TargetCenter-
184 the center of the \l target-
185*/-
186void QQuickPinchHandler::setPinchOrigin(QQuickPinchHandler::PinchOrigin pinchOrigin)-
187{-
188 if (m_pinchOrigin == pinchOrigin)
m_pinchOrigin == pinchOriginDescription
TRUEnever evaluated
FALSEnever evaluated
0
189 return;
never executed: return;
0
190-
191 m_pinchOrigin = pinchOrigin;-
192 emit pinchOriginChanged();-
193}
never executed: end of block
0
194-
195/*!-
196 \qmlproperty real QtQuick::PinchHandler::minimumX-
197-
198 The minimum acceptable x coordinate of the centroid-
199*/-
200void QQuickPinchHandler::setMinimumX(qreal minX)-
201{-
202 if (m_minimumX == minX)
m_minimumX == minXDescription
TRUEnever evaluated
FALSEnever evaluated
0
203 return;
never executed: return;
0
204 m_minimumX = minX;-
205 emit minimumXChanged();-
206}
never executed: end of block
0
207-
208/*!-
209 \qmlproperty real QtQuick::PinchHandler::maximumX-
210-
211 The maximum acceptable x coordinate of the centroid-
212*/-
213void QQuickPinchHandler::setMaximumX(qreal maxX)-
214{-
215 if (m_maximumX == maxX)
m_maximumX == maxXDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 return;
never executed: return;
0
217 m_maximumX = maxX;-
218 emit maximumXChanged();-
219}
never executed: end of block
0
220-
221/*!-
222 \qmlproperty real QtQuick::PinchHandler::minimumY-
223-
224 The minimum acceptable y coordinate of the centroid-
225*/-
226void QQuickPinchHandler::setMinimumY(qreal minY)-
227{-
228 if (m_minimumY == minY)
m_minimumY == minYDescription
TRUEnever evaluated
FALSEnever evaluated
0
229 return;
never executed: return;
0
230 m_minimumY = minY;-
231 emit minimumYChanged();-
232}
never executed: end of block
0
233-
234/*!-
235 \qmlproperty real QtQuick::PinchHandler::maximumY-
236-
237 The maximum acceptable y coordinate of the centroid-
238*/-
239void QQuickPinchHandler::setMaximumY(qreal maxY)-
240{-
241 if (m_maximumY == maxY)
m_maximumY == maxYDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 return;
never executed: return;
0
243 m_maximumY = maxY;-
244 emit maximumYChanged();-
245}
never executed: end of block
0
246-
247bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event)-
248{-
249 if (!QQuickMultiPointHandler::wantsPointerEvent(event))
!QQuickMultiPo...erEvent(event)Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
31-52
250 return false;
executed 52 times by 1 test: return false;
Executed by:
  • tst_multipointtoucharea_interop
52
251-
252#if QT_CONFIG(gestures)-
253 if (const auto gesture = event->asPointerNativeGestureEvent()) {
const auto ges...GestureEvent()Description
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-31
254 if (minimumPointCount() == 2) {
minimumPointCount() == 2Description
TRUEnever evaluated
FALSEnever evaluated
0
255 switch (gesture->type()) {-
256 case Qt::BeginNativeGesture:
never executed: case Qt::BeginNativeGesture:
0
257 case Qt::EndNativeGesture:
never executed: case Qt::EndNativeGesture:
0
258 case Qt::ZoomNativeGesture:
never executed: case Qt::ZoomNativeGesture:
0
259 case Qt::RotateNativeGesture:
never executed: case Qt::RotateNativeGesture:
0
260 return parentContains(event->point(0));
never executed: return parentContains(event->point(0));
0
261 default:
never executed: default:
0
262 return false;
never executed: return false;
0
263 }-
264 } else {-
265 return false;
never executed: return false;
0
266 }-
267 }-
268#endif-
269-
270 return true;
executed 31 times by 1 test: return true;
Executed by:
  • tst_multipointtoucharea_interop
31
271}-
272-
273/*!-
274 \qmlproperty int QtQuick::PinchHandler::minimumTouchPoints-
275-
276 The pinch begins when this number of fingers are pressed.-
277 Until then, PinchHandler tracks the positions of any pressed fingers,-
278 but if it's an insufficient number, it does not scale or rotate-
279 its \l target, and the \l active property will remain false.-
280*/-
281-
282/*!-
283 \qmlproperty bool QtQuick::PinchHandler::active-
284-
285 This property is true when all the constraints (epecially \l minimumTouchPoints)-
286 are satisfied and the \l target, if any, is being manipulated.-
287*/-
288-
289void QQuickPinchHandler::onActiveChanged()-
290{-
291 QQuickMultiPointHandler::onActiveChanged();-
292 if (active()) {
active()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
4
293 m_startMatrix = QMatrix4x4();-
294 m_startAngles = angles(m_centroid.sceneGrabPosition());-
295 m_startDistance = averageTouchPointDistance(m_centroid.sceneGrabPosition());-
296 m_activeRotation = 0;-
297 m_activeTranslation = QVector2D();-
298 if (const QQuickItem *t = target()) {
const QQuickItem *t = target()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
0-4
299 m_startScale = t->scale(); // TODO incompatible with independent x/y scaling-
300 m_startRotation = t->rotation();-
301 QVector3D xformOrigin(t->transformOriginPoint());-
302 m_startMatrix.translate(t->x(), t->y());-
303 m_startMatrix.translate(xformOrigin);-
304 m_startMatrix.scale(m_startScale);-
305 m_startMatrix.rotate(m_startRotation, 0, 0, -1);-
306 m_startMatrix.translate(-xformOrigin);-
307 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
308 m_startScale = m_accumulatedScale;-
309 m_startRotation = 0;-
310 }
never executed: end of block
0
311 qCInfo(lcPinchHandler) << "activated with starting scale" << m_startScale << "rotation" << m_startRotation;
executed 4 times by 1 test: QMessageLogger(__FILE__, 311, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).info() << "activated with starting scale" << m_startScale << "rotation" << m_startRotation;
Executed by:
  • tst_multipointtoucharea_interop
qt_category_enabledDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
4
312 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
313 qCInfo(lcPinchHandler) << "deactivated with scale" << m_activeScale << "rotation" << m_activeRotation;
executed 4 times by 1 test: QMessageLogger(__FILE__, 313, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).info() << "deactivated with scale" << m_activeScale << "rotation" << m_activeRotation;
Executed by:
  • tst_multipointtoucharea_interop
qt_category_enabledDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
4
314 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
315}-
316-
317void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event)-
318{-
319 if (Q_UNLIKELY(lcPinchHandler().isDebugEnabled())) {
__builtin_expe...led()), false)Description
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-31
320 for (QQuickEventPoint *point : qAsConst(m_currentPoints))-
321 qCDebug(lcPinchHandler) << point->state() << point->sceneGrabPosition() << "->" << point->scenePosition();
never executed: QMessageLogger(__FILE__, 321, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << point->state() << point->sceneGrabPosition() << "->" << point->scenePosition();
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
322 }
never executed: end of block
0
323 QQuickMultiPointHandler::handlePointerEventImpl(event);-
324-
325 qreal dist = 0;-
326#if QT_CONFIG(gestures)-
327 if (const auto gesture = event->asPointerNativeGestureEvent()) {
const auto ges...GestureEvent()Description
TRUEnever evaluated
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-31
328 switch (gesture->type()) {-
329 case Qt::EndNativeGesture:
never executed: case Qt::EndNativeGesture:
0
330 m_activeScale = 1;-
331 m_activeRotation = 0;-
332 m_activeTranslation = QVector2D();-
333 m_centroid.reset();-
334 setActive(false);-
335 emit updated();-
336 return;
never executed: return;
0
337 case Qt::ZoomNativeGesture:
never executed: case Qt::ZoomNativeGesture:
0
338 m_activeScale *= 1 + gesture->value();-
339 break;
never executed: break;
0
340 case Qt::RotateNativeGesture:
never executed: case Qt::RotateNativeGesture:
0
341 m_activeRotation += gesture->value();-
342 break;
never executed: break;
0
343 default:
never executed: default:
0
344 // Nothing of interest (which is unexpected, because wantsPointerEvent() should have returned false)-
345 return;
never executed: return;
0
346 }-
347 if (!active()) {
!active()Description
TRUEnever evaluated
FALSEnever evaluated
0
348 setActive(true);-
349 // Native gestures for 2-finger pinch do not allow dragging, so-
350 // the centroid won't move during the gesture, and translation stays at zero-
351 m_activeTranslation = QVector2D();-
352 }
never executed: end of block
0
353 } else
never executed: end of block
0
354#endif // QT_CONFIG(gestures)-
355 {-
356 bool containsReleasedPoints = event->isReleaseEvent();-
357 if (!active()) {
!active()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 25 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
6-25
358 // Verify that at least one of the points has moved beyond threshold needed to activate the handler-
359 for (QQuickEventPoint *point : qAsConst(m_currentPoints)) {-
360 if (!containsReleasedPoints && QQuickWindowPrivate::dragOverThreshold(point) && grabPoints(m_currentPoints)) {
!containsReleasedPointsDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
QQuickWindowPr...reshold(point)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
grabPoints(m_currentPoints)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
0-6
361 setActive(true);-
362 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_multipointtoucharea_interop
4
363 } else {-
364 setPassiveGrab(point);-
365 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
6
366 if (point->state() == QQuickEventPoint::Pressed) {
point->state()...Point::PressedDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-6
367 point->setAccepted(false); // don't stop propagation-
368 setPassiveGrab(point);-
369 }
never executed: end of block
0
370 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
6
371 if (!active())
!active()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
2-4
372 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_multipointtoucharea_interop
2
373 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
4
374 // TODO check m_pinchOrigin: right now it acts like it's set to PinchCenter-
375 // avoid mapping the minima and maxima, as they might have unmappable values-
376 // such as -inf/+inf. Because of this we perform the bounding to min/max in local coords.-
377 // 1. scale-
378 dist = averageTouchPointDistance(m_centroid.scenePosition());-
379 m_activeScale = dist / m_startDistance;-
380 m_activeScale = qBound(m_minimumScale/m_startScale, m_activeScale, m_maximumScale/m_startScale);-
381-
382 // 2. rotate-
383 QVector<PointData> newAngles = angles(m_centroid.scenePosition());-
384 const qreal angleDelta = averageAngleDelta(m_startAngles, newAngles);-
385 m_activeRotation += angleDelta;-
386 m_startAngles = std::move(newAngles);-
387-
388 if (!containsReleasedPoints)
!containsReleasedPointsDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
0-29
389 acceptPoints(m_currentPoints);
executed 29 times by 1 test: acceptPoints(m_currentPoints);
Executed by:
  • tst_multipointtoucharea_interop
29
390 }
executed 29 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
29
391-
392 QPointF centroidParentPos;-
393 QRectF bounds(m_minimumX, m_minimumY, m_maximumX - m_minimumX, m_maximumY - m_minimumY);-
394 if (target() && target()->parentItem()) {
target()Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
target()->parentItem()Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
0-29
395 centroidParentPos = target()->parentItem()->mapFromScene(m_centroid.scenePosition());-
396 centroidParentPos = QPointF(qBound(bounds.left(), centroidParentPos.x(), bounds.right()),-
397 qBound(bounds.top(), centroidParentPos.y(), bounds.bottom()));-
398 }
executed 29 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
29
399 const qreal totalRotation = m_startRotation + m_activeRotation;-
400 const qreal rotation = qBound(m_minimumRotation, totalRotation, m_maximumRotation);-
401 m_activeRotation += (rotation - totalRotation); //adjust for the potential bounding above-
402 m_accumulatedScale = m_startScale * m_activeScale;-
403-
404 if (target() && target()->parentItem()) {
target()Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
target()->parentItem()Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
FALSEnever evaluated
0-29
405 // 3. Drag/translate-
406 const QPointF centroidStartParentPos = target()->parentItem()->mapFromScene(m_centroid.sceneGrabPosition());-
407 m_activeTranslation = QVector2D(centroidParentPos - centroidStartParentPos);-
408 // apply rotation + scaling around the centroid - then apply translation.-
409 QMatrix4x4 mat;-
410-
411 const QVector3D centroidParentVector(centroidParentPos);-
412 mat.translate(centroidParentVector);-
413 mat.rotate(m_activeRotation, 0, 0, 1);-
414 mat.scale(m_activeScale);-
415 mat.translate(-centroidParentVector);-
416 mat.translate(QVector3D(m_activeTranslation));-
417-
418 mat = mat * m_startMatrix;-
419-
420 QPointF xformOriginPoint = target()->transformOriginPoint();-
421 QPointF pos = mat * xformOriginPoint;-
422 pos -= xformOriginPoint;-
423-
424 target()->setPosition(pos);-
425 target()->setRotation(rotation);-
426 target()->setScale(m_accumulatedScale);-
427-
428 // TODO some translation inadvertently happens; try to hold the chosen pinch origin in place-
429 } else {
executed 29 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
29
430 m_activeTranslation = QVector2D(m_centroid.scenePosition() - m_centroid.scenePressPosition());-
431 }
never executed: end of block
0
432-
433 qCDebug(lcPinchHandler) << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition()
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
qt_category_enabledDescription
TRUEnever evaluated
FALSEevaluated 29 times by 1 test
Evaluated by:
  • tst_multipointtoucharea_interop
0-29
434 << ", distance" << m_startDistance << "->" << dist
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
0
435 << ", startScale" << m_startScale << "->" << m_accumulatedScale
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
0
436 << ", activeRotation" << m_activeRotation
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
0
437 << ", rotation" << rotation
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
0
438 << " from " << event->device()->type();
never executed: QMessageLogger(__FILE__, 433, __PRETTY_FUNCTION__, lcPinchHandler().categoryName()).debug() << "centroid" << m_centroid.scenePressPosition() << "->" << m_centroid.scenePosition() << ", distance" << m_startDistance << "->" << dist << ", startScale" << m_startScale << "->" << m_accumulatedScale << ", activeRotation" << m_activeRotation << ", rotation" << rotation << " from " << event->device()->type();
0
439-
440 emit updated();-
441}
executed 29 times by 1 test: end of block
Executed by:
  • tst_multipointtoucharea_interop
29
442-
443/*!-
444 \readonly-
445 \qmlproperty QPointF QtQuick::PinchHandler::centroid-
446-
447 A point exactly in the middle of the currently-pressed touch points.-
448 If \l pinchOrigin is set to \c PinchCenter, the \l target will be rotated-
449 around this point.-
450*/-
451-
452/*!-
453 \readonly-
454 \qmlproperty real QtQuick::PinchHandler::scale-
455-
456 The scale factor that will automatically be set on the \l target if it is not null.-
457 Otherwise, bindings can be used to do arbitrary things with this value.-
458 While the pinch gesture is being performed, it is continuously multiplied by-
459 \l activeScale; after the gesture ends, it stays the same; and when the next-
460 pinch gesture begins, it begins to be multiplied by activeScale again.-
461*/-
462-
463/*!-
464 \readonly-
465 \qmlproperty real QtQuick::PinchHandler::activeScale-
466-
467 The scale factor while the pinch gesture is being performed.-
468 It is 1.0 when the gesture begins, increases as the touchpoints are spread-
469 apart, and decreases as the touchpoints are brought together.-
470 If \l target is not null, its \l {Item::scale}{scale} will be automatically-
471 multiplied by this value.-
472 Otherwise, bindings can be used to do arbitrary things with this value.-
473*/-
474-
475/*!-
476 \readonly-
477 \qmlproperty real QtQuick::PinchHandler::rotation-
478-
479 The rotation of the pinch gesture in degrees, with positive values clockwise.-
480 It is 0 when the gesture begins. If \l target is not null, this will be-
481 automatically applied to its \l {Item::rotation}{rotation}. Otherwise,-
482 bindings can be used to do arbitrary things with this value.-
483*/-
484-
485/*!-
486 \readonly-
487 \qmlproperty QVector2D QtQuick::PinchHandler::translation-
488-
489 The translation of the gesture \l centroid. It is \c (0, 0) when the-
490 gesture begins.-
491*/-
492-
493QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0