on xenial help sign in
AxisVelCalc: Put updateIdleTime() inside calculate()
commitd27a582642e5cb2149bc486169422ffcc9712ed8 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 26 Jun 2013, 13:20 (13 years ago) parentd96921e
4 files changed+12−12
Components/DragHandle.qml−1 Components/Stage.qml−1 plugins/Ubuntu/Gestures/AxisVelocityCalculator.cpp+2−1 plugins/Ubuntu/Gestures/AxisVelocityCalculator.h+10−9
Components/DragHandle.qml−1
@@ -107,7 +107,6 @@ DirectionalDragArea {
107107
108108 onStatusChanged: {
109109 if (status === DirectionalDragArea.WaitingForTouch) {
110− dragEvaluator.updateIdleTime()
111110 if (__previousStatus === DirectionalDragArea.Recognized) {
112111 __onFinishedRecognizedGesture()
113112 }
Components/Stage.qml−1
@@ -474,7 +474,6 @@ Showable {
474474 switchToApplicationAnimationController.completeToBeginningWithSignal();
475475 gotRejected = true;
476476 } else if (status == DirectionalDragArea.WaitingForTouch) {
477− dragEvaluator.updateIdleTime()
478477 if (!gotRejected)
479478 onGestureEnded()
480479 }
plugins/Ubuntu/Gestures/AxisVelocityCalculator.cpp+2−1
@@ -82,11 +82,12 @@ void AxisVelocityCalculator::processMovement(qreal movement)
8282 m_samplesWrite = (m_samplesWrite + 1) % MAX_SAMPLES;
8383}
8484
85−qreal AxisVelocityCalculator::calculate() const
85+qreal AxisVelocityCalculator::calculate()
8686{
8787 if (numSamples() < MIN_SAMPLES_NEEDED) {
8888 return 0.0;
8989 }
90+ updateIdleTime(); // consider the time elapsed since the last update and now
9091
9192 int lastIndex;
9293 if (m_samplesWrite == 0) {
plugins/Ubuntu/Gestures/AxisVelocityCalculator.h+10−9
@@ -82,18 +82,10 @@ public:
8282 qreal trackedPosition() const;
8383 void setTrackedPosition(qreal value);
8484
85− /*
86− Inform that trackedPosition remained motionless since the time it was
87− last changed.
88−
89− It's the same as calling setTrackedPosition(trackedPosition())
90− */
91− Q_INVOKABLE void updateIdleTime();
92−
9385 /*
9486 Calculates the finger velocity, in axis units/millisecond
9587 */
96− Q_INVOKABLE qreal calculate() const;
88+ Q_INVOKABLE qreal calculate();
9789
9890 /*
9991 Removes all stored movements from previous calls to setTrackedPosition()
@@ -127,6 +119,15 @@ Q_SIGNALS:
127119 void trackedPositionChanged(qreal value);
128120
129121private:
122+
123+ /*
124+ Inform that trackedPosition remained motionless since the time it was
125+ last changed.
126+
127+ It's the same as calling setTrackedPosition(trackedPosition())
128+ */
129+ void updateIdleTime();
130+
130131 /*
131132 How much the finger has moved since processMovement() was last called.
132133 */