From d57baa9be741e0db90e08cc39ba8d488f58c40f5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 7 Jan 2011 14:10:08 +1000 Subject: PinchArea API changes following review. Task-number: QTBUG-15491 Reviewed-by: Michael Brasser --- .../touchinteraction/pincharea/flickresize.qml | 6 ++-- .../graphicsitems/qdeclarativepincharea.cpp | 42 +++++++++++----------- .../graphicsitems/qdeclarativepincharea_p.h | 20 +++++------ .../qdeclarativepincharea/data/pinchproperties.qml | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/declarative/touchinteraction/pincharea/flickresize.qml b/examples/declarative/touchinteraction/pincharea/flickresize.qml index 8f29d6d..aa426e7 100644 --- a/examples/declarative/touchinteraction/pincharea/flickresize.qml +++ b/examples/declarative/touchinteraction/pincharea/flickresize.qml @@ -56,11 +56,11 @@ Rectangle { height: Math.max(flick.contentHeight, flick.height) onPinchChanged: { // adjust content pos due to drag - flick.contentX += pinch.lastCenter.x - pinch.center.x - flick.contentY += pinch.lastCenter.y - pinch.center.y + flick.contentX += pinch.previousCenter.x - pinch.center.x + flick.contentY += pinch.previousCenter.y - pinch.center.y // resize content - var scale = 1.0 + pinch.scale - pinch.lastScale + var scale = 1.0 + pinch.scale - pinch.previousScale flick.resizeContent(flick.contentWidth * scale, flick.contentHeight * scale, pinch.center) } diff --git a/src/declarative/graphicsitems/qdeclarativepincharea.cpp b/src/declarative/graphicsitems/qdeclarativepincharea.cpp index 998c30d..436099e 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea.cpp +++ b/src/declarative/graphicsitems/qdeclarativepincharea.cpp @@ -58,11 +58,11 @@ QT_BEGIN_NAMESPACE \bold {The PinchEvent element was added in QtQuick 1.1} - The \c center, \c startCenter, \c lastCenter properties provide the center position between the two touch points. + The \c center, \c startCenter, \c previousCenter properties provide the center position between the two touch points. - The \c scale and \c lastScale properties provide the scale factor. + The \c scale and \c previousScale properties provide the scale factor. - The \c angle, \c lastAngle and \c rotation properties provide the angle between the two points and the amount of rotation. + The \c angle, \c previousAngle and \c rotation properties provide the angle between the two points and the amount of rotation. The \c point1, \c point2, \c startPoint1, \c startPoint2 properties provide the positions of the touch points. @@ -75,26 +75,26 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty QPointF PinchEvent::center \qmlproperty QPointF PinchEvent::startCenter - \qmlproperty QPointF PinchEvent::lastCenter + \qmlproperty QPointF PinchEvent::previousCenter These properties hold the position of the center point between the two touch points. \list \o \c center is the current center point - \o \c lastCenter is the center point of the previous event. + \o \c previousCenter is the center point of the previous event. \o \c startCenter is the center point when the gesture began \endlist */ /*! \qmlproperty real PinchEvent::scale - \qmlproperty real PinchEvent::lastScale + \qmlproperty real PinchEvent::previousScale These properties hold the scale factor determined by the change in distance between the two touch points. \list \o \c scale is the current scale factor. - \o \c lastScale is the scale factor of the previous event. + \o \c previousScale is the scale factor of the previous event. \endlist When a pinch gesture is started, the scale is 1.0. @@ -102,14 +102,14 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty real PinchEvent::angle - \qmlproperty real PinchEvent::lastAngle + \qmlproperty real PinchEvent::previousAngle \qmlproperty real PinchEvent::rotation These properties hold the angle between the two touch points. \list \o \c angle is the current angle between the two points in the range -180 to 180. - \o \c lastAngle is the angle of the previous event. + \o \c previousAngle is the angle of the previous event. \o \c rotation is the total rotation since the pinch gesture started. \endlist @@ -169,7 +169,7 @@ QDeclarativePinchAreaPrivate::~QDeclarativePinchAreaPrivate() \list \o setting a \c pinch.target to provide automatic interaction with an element - \o using the onPinchStarted, onPinchChanged and onPinchFinished handlers + \o using the onPinchStarted, onPinchUpdated and onPinchFinished handlers \endlist \sa PinchEvent @@ -188,7 +188,7 @@ QDeclarativePinchAreaPrivate::~QDeclarativePinchAreaPrivate() */ /*! - \qmlsignal PinchArea::onPinchChanged() + \qmlsignal PinchArea::onPinchUpdated() This handler is called when the pinch area detects that a pinch gesture has changed. @@ -304,9 +304,9 @@ void QDeclarativePinchArea::updatePinch() QPointF pinchCenter = mapFromScene(d->sceneLastCenter); QDeclarativePinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, rotationAngle); pe.setStartCenter(d->pinchStartCenter); - pe.setLastCenter(pinchCenter); - pe.setLastAngle(d->pinchLastAngle); - pe.setLastScale(d->pinchLastScale); + pe.setPreviousCenter(pinchCenter); + pe.setPreviousAngle(d->pinchLastAngle); + pe.setPreviousScale(d->pinchLastScale); pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); pe.setPoint1(d->lastPoint1); @@ -352,9 +352,9 @@ void QDeclarativePinchArea::updatePinch() d->lastPoint2 = d->touchPoints.at(1).pos(); QDeclarativePinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); pe.setStartCenter(d->pinchStartCenter); - pe.setLastCenter(d->pinchStartCenter); - pe.setLastAngle(d->pinchLastAngle); - pe.setLastScale(d->pinchLastScale); + pe.setPreviousCenter(d->pinchStartCenter); + pe.setPreviousAngle(d->pinchLastAngle); + pe.setPreviousScale(d->pinchLastScale); pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); pe.setPoint1(d->lastPoint1); @@ -383,9 +383,9 @@ void QDeclarativePinchArea::updatePinch() QPointF pinchCenter = mapFromScene(sceneCenter); QDeclarativePinchEvent pe(pinchCenter, scale, angle, rotationAngle); pe.setStartCenter(d->pinchStartCenter); - pe.setLastCenter(mapFromScene(d->sceneLastCenter)); - pe.setLastAngle(d->pinchLastAngle); - pe.setLastScale(d->pinchLastScale); + pe.setPreviousCenter(mapFromScene(d->sceneLastCenter)); + pe.setPreviousAngle(d->pinchLastAngle); + pe.setPreviousScale(d->pinchLastScale); pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); pe.setPoint1(d->touchPoints.at(0).pos()); @@ -395,7 +395,7 @@ void QDeclarativePinchArea::updatePinch() d->pinchLastAngle = angle; d->lastPoint1 = d->touchPoints.at(0).pos(); d->lastPoint2 = d->touchPoints.at(1).pos(); - emit pinchChanged(&pe); + emit pinchUpdated(&pe); if (d->pinch && d->pinch->target()) { qreal s = d->pinchStartScale * scale; s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale()); diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p.h index 9a73a17..cd5423d 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea_p.h +++ b/src/declarative/graphicsitems/qdeclarativepincharea_p.h @@ -193,11 +193,11 @@ class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject Q_PROPERTY(QPointF center READ center) Q_PROPERTY(QPointF startCenter READ startCenter) - Q_PROPERTY(QPointF lastCenter READ lastCenter) + Q_PROPERTY(QPointF previousCenter READ previousCenter) Q_PROPERTY(qreal scale READ scale) - Q_PROPERTY(qreal lastScale READ lastScale) + Q_PROPERTY(qreal previousScale READ previousScale) Q_PROPERTY(qreal angle READ angle) - Q_PROPERTY(qreal lastAngle READ lastAngle) + Q_PROPERTY(qreal previousAngle READ previousAngle) Q_PROPERTY(qreal rotation READ rotation) Q_PROPERTY(QPointF point1 READ point1) Q_PROPERTY(QPointF startPoint1 READ startPoint1) @@ -212,14 +212,14 @@ public: QPointF center() const { return m_center; } QPointF startCenter() const { return m_startCenter; } void setStartCenter(QPointF c) { m_startCenter = c; } - QPointF lastCenter() const { return m_lastCenter; } - void setLastCenter(QPointF c) { m_lastCenter = c; } + QPointF previousCenter() const { return m_lastCenter; } + void setPreviousCenter(QPointF c) { m_lastCenter = c; } qreal scale() const { return m_scale; } - qreal lastScale() const { return m_lastScale; } - void setLastScale(qreal s) { m_lastScale = s; } + qreal previousScale() const { return m_lastScale; } + void setPreviousScale(qreal s) { m_lastScale = s; } qreal angle() const { return m_angle; } - qreal lastAngle() const { return m_lastAngle; } - void setLastAngle(qreal a) { m_lastAngle = a; } + qreal previousAngle() const { return m_lastAngle; } + void setPreviousAngle(qreal a) { m_lastAngle = a; } qreal rotation() const { return m_rotation; } QPointF point1() const { return m_point1; } void setPoint1(QPointF p) { m_point1 = p; } @@ -271,7 +271,7 @@ public: Q_SIGNALS: void enabledChanged(); void pinchStarted(QDeclarativePinchEvent *pinch); - void pinchChanged(QDeclarativePinchEvent *pinch); + void pinchUpdated(QDeclarativePinchEvent *pinch); void pinchFinished(QDeclarativePinchEvent *pinch); protected: diff --git a/tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml b/tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml index f39ea06..0b59d9d 100644 --- a/tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml +++ b/tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml @@ -33,7 +33,7 @@ Rectangle { whiteRect.center = pinch.center whiteRect.scale = pinch.scale } - onPinchChanged: { + onPinchUpdated: { whiteRect.center = pinch.center whiteRect.scale = pinch.scale } -- cgit v0.12