on xenial help sign in
AxisVelCalc: Put updateIdleTime() inside calculate()
d27a582Daniel d'Andrada
Components/DragHandle.qml−1
@@ -107,7 +107,6 @@ DirectionalDragArea {
107
107
108 onStatusChanged: {
108 onStatusChanged: {
109 if (status === DirectionalDragArea.WaitingForTouch) {
109 if (status === DirectionalDragArea.WaitingForTouch) {
110− dragEvaluator.updateIdleTime()
111 if (__previousStatus === DirectionalDragArea.Recognized) {
110 if (__previousStatus === DirectionalDragArea.Recognized) {
112 __onFinishedRecognizedGesture()
111 __onFinishedRecognizedGesture()
113 }
112 }
Components/Stage.qml−1
@@ -474,7 +474,6 @@ Showable {
474 switchToApplicationAnimationController.completeToBeginningWithSignal();
474 switchToApplicationAnimationController.completeToBeginningWithSignal();
475 gotRejected = true;
475 gotRejected = true;
476 } else if (status == DirectionalDragArea.WaitingForTouch) {
476 } else if (status == DirectionalDragArea.WaitingForTouch) {
477− dragEvaluator.updateIdleTime()
478 if (!gotRejected)
477 if (!gotRejected)
479 onGestureEnded()
478 onGestureEnded()
480 }
479 }
plugins/Ubuntu/Gestures/AxisVelocityCalculator.cpp+2−1
@@ -82,11 +82,12 @@ void AxisVelocityCalculator::processMovement(qreal movement)
82 m_samplesWrite = (m_samplesWrite + 1) % MAX_SAMPLES;
82 m_samplesWrite = (m_samplesWrite + 1) % MAX_SAMPLES;
83}
83}
84
84
85−qreal AxisVelocityCalculator::calculate() const
85+qreal AxisVelocityCalculator::calculate()
86{
86{
87 if (numSamples() < MIN_SAMPLES_NEEDED) {
87 if (numSamples() < MIN_SAMPLES_NEEDED) {
88 return 0.0;
88 return 0.0;
89 }
89 }
90+ updateIdleTime(); // consider the time elapsed since the last update and now
90
91
91 int lastIndex;
92 int lastIndex;
92 if (m_samplesWrite == 0) {
93 if (m_samplesWrite == 0) {
plugins/Ubuntu/Gestures/AxisVelocityCalculator.h+10−9
@@ -82,18 +82,10 @@ public:
82 qreal trackedPosition() const;
82 qreal trackedPosition() const;
83 void setTrackedPosition(qreal value);
83 void setTrackedPosition(qreal value);
84
84
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−
93 /*
85 /*
94 Calculates the finger velocity, in axis units/millisecond
86 Calculates the finger velocity, in axis units/millisecond
95 */
87 */
96− Q_INVOKABLE qreal calculate() const;
88+ Q_INVOKABLE qreal calculate();
97
89
98 /*
90 /*
99 Removes all stored movements from previous calls to setTrackedPosition()
91 Removes all stored movements from previous calls to setTrackedPosition()
@@ -127,6 +119,15 @@ Q_SIGNALS:
127 void trackedPositionChanged(qreal value);
119 void trackedPositionChanged(qreal value);
128
120
129private:
121private:
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+
130 /*
131 /*
131 How much the finger has moved since processMovement() was last called.
132 How much the finger has moved since processMovement() was last called.
132 */
133 */