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/events/gestures/gesture_sequence.h" | 5 #include "ui/events/gestures/gesture_sequence.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 if (scroll_type_ == ST_HORIZONTAL) | 982 if (scroll_type_ == ST_HORIZONTAL) |
983 railed_y_velocity = 0; | 983 railed_y_velocity = 0; |
984 else if (scroll_type_ == ST_VERTICAL) | 984 else if (scroll_type_ == ST_VERTICAL) |
985 railed_x_velocity = 0; | 985 railed_x_velocity = 0; |
986 | 986 |
987 if (railed_x_velocity != 0 || railed_y_velocity != 0) { | 987 if (railed_x_velocity != 0 || railed_y_velocity != 0) { |
988 | 988 |
989 gestures->push_back(CreateGestureEvent( | 989 gestures->push_back(CreateGestureEvent( |
990 GestureEventDetails(ui::ET_SCROLL_FLING_START, | 990 GestureEventDetails(ui::ET_SCROLL_FLING_START, |
991 CalibrateFlingVelocity(railed_x_velocity), | 991 CalibrateFlingVelocity(railed_x_velocity), |
992 CalibrateFlingVelocity(railed_y_velocity), | 992 CalibrateFlingVelocity(railed_y_velocity)), |
993 CalibrateFlingVelocity(x_velocity), | |
994 CalibrateFlingVelocity(y_velocity)), | |
995 location, | 993 location, |
996 flags_, | 994 flags_, |
997 base::Time::FromDoubleT(point.last_touch_time()), | 995 base::Time::FromDoubleT(point.last_touch_time()), |
998 1 << point.touch_id())); | 996 1 << point.touch_id())); |
999 } else { | 997 } else { |
1000 gestures->push_back(CreateGestureEvent( | 998 gestures->push_back(CreateGestureEvent( |
1001 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), | 999 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), |
1002 location, | 1000 location, |
1003 flags_, | 1001 flags_, |
1004 base::Time::FromDoubleT(point.last_touch_time()), | 1002 base::Time::FromDoubleT(point.last_touch_time()), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 | 1035 |
1038 if (is_first_scroll == FS_FIRST_SCROLL) { | 1036 if (is_first_scroll == FS_FIRST_SCROLL) { |
1039 float slop = GestureConfiguration::max_touch_move_in_pixels_for_click(); | 1037 float slop = GestureConfiguration::max_touch_move_in_pixels_for_click(); |
1040 float length = d.Length(); | 1038 float length = d.Length(); |
1041 float ratio = std::max((length - slop) / length, 0.0f); | 1039 float ratio = std::max((length - slop) / length, 0.0f); |
1042 | 1040 |
1043 d.set_x(d.x() * ratio); | 1041 d.set_x(d.x() * ratio); |
1044 d.set_y(d.y() * ratio); | 1042 d.set_y(d.y() * ratio); |
1045 } | 1043 } |
1046 | 1044 |
1047 gfx::Vector2dF o = d; | |
1048 | |
1049 if (scroll_type_ == ST_HORIZONTAL) | 1045 if (scroll_type_ == ST_HORIZONTAL) |
1050 d.set_y(0); | 1046 d.set_y(0); |
1051 else if (scroll_type_ == ST_VERTICAL) | 1047 else if (scroll_type_ == ST_VERTICAL) |
1052 d.set_x(0); | 1048 d.set_x(0); |
1053 if (d.IsZero()) | 1049 if (d.IsZero()) |
1054 return; | 1050 return; |
1055 | 1051 |
1056 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, | 1052 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, d.x(), d.y()); |
1057 d.x(), d.y(), o.x(), o.y()); | |
1058 gestures->push_back(CreateGestureEvent( | 1053 gestures->push_back(CreateGestureEvent( |
1059 details, | 1054 details, |
1060 location, | 1055 location, |
1061 flags_, | 1056 flags_, |
1062 base::Time::FromDoubleT(point.last_touch_time()), | 1057 base::Time::FromDoubleT(point.last_touch_time()), |
1063 ComputeTouchBitmask(points_))); | 1058 ComputeTouchBitmask(points_))); |
1064 } | 1059 } |
1065 | 1060 |
1066 void GestureSequence::AppendPinchGestureBegin(const GesturePoint& p1, | 1061 void GestureSequence::AppendPinchGestureBegin(const GesturePoint& p1, |
1067 const GesturePoint& p2, | 1062 const GesturePoint& p2, |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 } | 1471 } |
1477 | 1472 |
1478 void GestureSequence::StartRailFreeScroll(const GesturePoint& point, | 1473 void GestureSequence::StartRailFreeScroll(const GesturePoint& point, |
1479 Gestures* gestures) { | 1474 Gestures* gestures) { |
1480 AppendScrollGestureBegin(point, point.first_touch_position(), gestures); | 1475 AppendScrollGestureBegin(point, point.first_touch_position(), gestures); |
1481 scroll_type_ = ST_FREE; | 1476 scroll_type_ = ST_FREE; |
1482 set_state(GS_SCROLL); | 1477 set_state(GS_SCROLL); |
1483 } | 1478 } |
1484 | 1479 |
1485 } // namespace ui | 1480 } // namespace ui |
OLD | NEW |