OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/gestures/gesture_point.h" | 5 #include "ui/base/gestures/gesture_point.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 GesturePoint::~GesturePoint() {} | 25 GesturePoint::~GesturePoint() {} |
26 | 26 |
27 void GesturePoint::Reset() { | 27 void GesturePoint::Reset() { |
28 first_touch_time_ = last_touch_time_ = 0.0; | 28 first_touch_time_ = last_touch_time_ = 0.0; |
29 velocity_calculator_.ClearHistory(); | 29 velocity_calculator_.ClearHistory(); |
30 point_id_ = -1; | 30 point_id_ = -1; |
31 } | 31 } |
32 | 32 |
| 33 void GesturePoint::ResetVelocity() { |
| 34 velocity_calculator_.ClearHistory(); |
| 35 } |
| 36 |
33 void GesturePoint::UpdateValues(const TouchEvent& event) { | 37 void GesturePoint::UpdateValues(const TouchEvent& event) { |
34 const int64 event_timestamp_microseconds = | 38 const int64 event_timestamp_microseconds = |
35 event.GetTimestamp().InMicroseconds(); | 39 event.GetTimestamp().InMicroseconds(); |
36 if (event.GetEventType() == ui::ET_TOUCH_MOVED) { | 40 if (event.GetEventType() == ui::ET_TOUCH_MOVED) { |
37 velocity_calculator_.PointSeen(event.GetLocation().x(), | 41 velocity_calculator_.PointSeen(event.GetLocation().x(), |
38 event.GetLocation().y(), | 42 event.GetLocation().y(), |
39 event_timestamp_microseconds); | 43 event_timestamp_microseconds); |
40 } | 44 } |
41 | 45 |
42 last_touch_time_ = event.GetTimestamp().InSecondsF(); | 46 last_touch_time_ = event.GetTimestamp().InSecondsF(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return manhattanDistance < | 166 return manhattanDistance < |
163 GestureConfiguration::max_touch_move_in_pixels_for_click(); | 167 GestureConfiguration::max_touch_move_in_pixels_for_click(); |
164 } | 168 } |
165 | 169 |
166 bool GesturePoint::IsOverMinFlickSpeed() { | 170 bool GesturePoint::IsOverMinFlickSpeed() { |
167 return velocity_calculator_.VelocitySquared() > | 171 return velocity_calculator_.VelocitySquared() > |
168 GestureConfiguration::min_flick_speed_squared(); | 172 GestureConfiguration::min_flick_speed_squared(); |
169 } | 173 } |
170 | 174 |
171 } // namespace ui | 175 } // namespace ui |
OLD | NEW |