summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-11-04 14:37:18 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-11-04 14:38:54 (GMT)
commit673973acc20ce4e068d63fa5b0391f5c785be8a3 (patch)
tree9b2f1cf075c768c6b00492c24d982c1ad03ff2a1 /examples
parent126638922389ca967c1a82b6254de8ac00042158 (diff)
downloadQt-673973acc20ce4e068d63fa5b0391f5c785be8a3.zip
Qt-673973acc20ce4e068d63fa5b0391f5c785be8a3.tar.gz
Qt-673973acc20ce4e068d63fa5b0391f5c785be8a3.tar.bz2
Mac: pinch gesture scales to fast and event below zero
Make the math correct. Plus, update the imagegesture example. Rev-By: denis
Diffstat (limited to 'examples')
-rw-r--r--examples/gestures/imagegestures/imagewidget.cpp13
-rw-r--r--examples/gestures/imagegestures/imagewidget.h1
2 files changed, 10 insertions, 4 deletions
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp
index f615129..df8f56d 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/gestures/imagegestures/imagewidget.cpp
@@ -50,7 +50,8 @@ ImageWidget::ImageWidget(QWidget *parent)
horizontalOffset(0),
verticalOffset(0),
rotationAngle(0),
- scaleFactor(1)
+ scaleFactor(1),
+ currentStepScaleFactor(1)
{
setMinimumSize(QSize(100,100));
@@ -85,7 +86,7 @@ void ImageWidget::paintEvent(QPaintEvent*)
p.translate(ww/2, wh/2);
p.translate(horizontalOffset, verticalOffset);
p.rotate(rotationAngle);
- p.scale(scaleFactor, scaleFactor);
+ p.scale(currentStepScaleFactor * scaleFactor, currentStepScaleFactor * scaleFactor);
p.translate(-iw/2, -ih/2);
p.drawImage(0, 0, currentImage);
}
@@ -140,8 +141,12 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture)
}
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal value = gesture->property("scaleFactor").toReal();
- qreal lastValue = gesture->property("lastScaleFactor").toReal();
- scaleFactor += value - lastValue;
+ if (gesture->state() == Qt::GestureFinished) {
+ scaleFactor *= currentStepScaleFactor;
+ currentStepScaleFactor = 1;
+ } else {
+ currentStepScaleFactor = value;
+ }
}
update();
}
diff --git a/examples/gestures/imagegestures/imagewidget.h b/examples/gestures/imagegestures/imagewidget.h
index 56e2316..7a68488 100644
--- a/examples/gestures/imagegestures/imagewidget.h
+++ b/examples/gestures/imagegestures/imagewidget.h
@@ -93,6 +93,7 @@ private:
float verticalOffset;
float rotationAngle;
float scaleFactor;
+ float currentStepScaleFactor;
//! [class definition end]
};
//! [class definition end]