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_sequence.h" | 5 #include "ui/base/gestures/gesture_sequence.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 const unsigned last_coefficient = | 289 const unsigned last_coefficient = |
290 GestureConfiguration::NumAccelParams - 1; | 290 GestureConfiguration::NumAccelParams - 1; |
291 float normalized_velocity = fabs(velocity * kFlingCurveNormalization); | 291 float normalized_velocity = fabs(velocity * kFlingCurveNormalization); |
292 float nu = 0.0f, x = 1.f; | 292 float nu = 0.0f, x = 1.f; |
293 | 293 |
294 for (int i = last_coefficient ; i >= 0; i--) { | 294 for (int i = last_coefficient ; i >= 0; i--) { |
295 float a = GestureConfiguration::fling_acceleration_curve_coefficients(i); | 295 float a = GestureConfiguration::fling_acceleration_curve_coefficients(i); |
296 nu += x * a; | 296 nu += x * a; |
297 x *= normalized_velocity; | 297 x *= normalized_velocity; |
298 } | 298 } |
299 return nu * velocity; | 299 if (velocity < 0.f) |
| 300 return std::max(nu * velocity, -GestureConfiguration::fling_velocity_cap()); |
| 301 else |
| 302 return std::min(nu * velocity, GestureConfiguration::fling_velocity_cap()); |
300 } | 303 } |
301 | 304 |
302 } // namespace | 305 } // namespace |
303 | 306 |
304 //////////////////////////////////////////////////////////////////////////////// | 307 //////////////////////////////////////////////////////////////////////////////// |
305 // GestureSequence Public: | 308 // GestureSequence Public: |
306 | 309 |
307 GestureSequence::GestureSequence(GestureEventHelper* helper) | 310 GestureSequence::GestureSequence(GestureEventHelper* helper) |
308 : state_(GS_NO_GESTURE), | 311 : state_(GS_NO_GESTURE), |
309 flags_(0), | 312 flags_(0), |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 return; | 1125 return; |
1123 | 1126 |
1124 // Since long press timer has been started, there should be a non-NULL point. | 1127 // Since long press timer has been started, there should be a non-NULL point. |
1125 const GesturePoint* point = GetPointByPointId(0); | 1128 const GesturePoint* point = GetPointByPointId(0); |
1126 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), | 1129 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), |
1127 event.location())) | 1130 event.location())) |
1128 GetLongPressTimer()->Stop(); | 1131 GetLongPressTimer()->Stop(); |
1129 } | 1132 } |
1130 | 1133 |
1131 } // namespace ui | 1134 } // namespace ui |
OLD | NEW |