summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 16:43:45 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 16:43:45 +0000
commit7599f4cc4105a86f94881e78ddf81b37fed528f4 (patch)
tree48704d46f4a103f44154584ec5217966005f59dd /ui/base
parentef08de96c04109ade75ece55ae228de4607ebaf7 (diff)
downloadchromium_src-7599f4cc4105a86f94881e78ddf81b37fed528f4.zip
chromium_src-7599f4cc4105a86f94881e78ddf81b37fed528f4.tar.gz
chromium_src-7599f4cc4105a86f94881e78ddf81b37fed528f4.tar.bz2
gesture recognizer: Reset velocities of the fingers after a pinch-end/swipe-end.
BUG=124592 TEST=none Review URL: https://chromiumcodereview.appspot.com/10191006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/gestures/gesture_point.cc4
-rw-r--r--ui/base/gestures/gesture_point.h2
-rw-r--r--ui/base/gestures/gesture_sequence.cc10
3 files changed, 14 insertions, 2 deletions
diff --git a/ui/base/gestures/gesture_point.cc b/ui/base/gestures/gesture_point.cc
index fc94f72..a9426d25 100644
--- a/ui/base/gestures/gesture_point.cc
+++ b/ui/base/gestures/gesture_point.cc
@@ -30,6 +30,10 @@ void GesturePoint::Reset() {
point_id_ = -1;
}
+void GesturePoint::ResetVelocity() {
+ velocity_calculator_.ClearHistory();
+}
+
void GesturePoint::UpdateValues(const TouchEvent& event) {
const int64 event_timestamp_microseconds =
event.GetTimestamp().InMicroseconds();
diff --git a/ui/base/gestures/gesture_point.h b/ui/base/gestures/gesture_point.h
index 9eee5b8..8ef28d6 100644
--- a/ui/base/gestures/gesture_point.h
+++ b/ui/base/gestures/gesture_point.h
@@ -23,6 +23,8 @@ class GesturePoint {
// Resets various states.
void Reset();
+ void ResetVelocity();
+
// Updates some states when a Tap gesture has been recognized for this point.
void UpdateForTap();
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index 89314ef..319713c 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -269,6 +269,9 @@ GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
case GST_THREE_FINGER_SWIPE_FIRST_CANCELLED:
case GST_THREE_FINGER_SWIPE_SECOND_CANCELLED:
case GST_THREE_FINGER_SWIPE_THIRD_CANCELLED:
+ GetPointByPointId(0)->ResetVelocity();
+ GetPointByPointId(1)->ResetVelocity();
+ GetPointByPointId(2)->ResetVelocity();
set_state(GS_PINCH);
break;
case GST_THREE_FINGER_SWIPE_FIRST_MOVED:
@@ -651,13 +654,16 @@ bool GestureSequence::PinchEnd(const TouchEvent& event,
const GesturePoint& point, Gestures* gestures) {
DCHECK(state_ == GS_PINCH);
- const GesturePoint* point1 = GetPointByPointId(0);
- const GesturePoint* point2 = GetPointByPointId(1);
+ GesturePoint* point1 = GetPointByPointId(0);
+ GesturePoint* point2 = GetPointByPointId(1);
float distance = point1->Distance(*point2);
AppendPinchGestureEnd(*point1, *point2,
distance / pinch_distance_start_, gestures);
+ point1->ResetVelocity();
+ point2->ResetVelocity();
+
pinch_distance_start_ = 0;
pinch_distance_current_ = 0;
return true;