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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 float x_velocity, | 635 float x_velocity, |
636 float y_velocity) { | 636 float y_velocity) { |
637 float railed_x_velocity = x_velocity; | 637 float railed_x_velocity = x_velocity; |
638 float railed_y_velocity = y_velocity; | 638 float railed_y_velocity = y_velocity; |
639 | 639 |
640 if (scroll_type_ == ST_HORIZONTAL) | 640 if (scroll_type_ == ST_HORIZONTAL) |
641 railed_y_velocity = 0; | 641 railed_y_velocity = 0; |
642 else if (scroll_type_ == ST_VERTICAL) | 642 else if (scroll_type_ == ST_VERTICAL) |
643 railed_x_velocity = 0; | 643 railed_x_velocity = 0; |
644 | 644 |
645 // TODO(rjkroege): It is conceivable that we could suppress sending the | |
646 // GestureScrollEnd if it is immediately followed by a GestureFlingStart. | |
647 gestures->push_back(CreateGestureEvent( | |
648 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), | |
649 location, | |
650 flags_, | |
651 base::Time::FromDoubleT(point.last_touch_time()), | |
652 1 << point.touch_id())); | |
653 | |
654 if (railed_x_velocity != 0 || railed_y_velocity != 0) { | 645 if (railed_x_velocity != 0 || railed_y_velocity != 0) { |
655 // TODO(sad|rjkroege): fling-curve is currently configured to work well with | 646 // TODO(sad|rjkroege): fling-curve is currently configured to work well with |
656 // touchpad scroll-events. This curve needs to be adjusted to work correctly | 647 // touchpad scroll-events. This curve needs to be adjusted to work correctly |
657 // with both touchpad and touchscreen. Until then, scale quadratically. | 648 // with both touchpad and touchscreen. Until then, scale quadratically. |
658 // http://crbug.com/120154 | 649 // http://crbug.com/120154 |
659 const float velocity_scaling = 1.f / 900.f; | 650 const float velocity_scaling = 1.f / 900.f; |
660 | 651 |
661 gestures->push_back(CreateGestureEvent( | 652 gestures->push_back(CreateGestureEvent( |
662 GestureEventDetails(ui::ET_SCROLL_FLING_START, | 653 GestureEventDetails(ui::ET_SCROLL_FLING_START, |
663 velocity_scaling * railed_x_velocity * fabsf(railed_x_velocity), | 654 velocity_scaling * railed_x_velocity * fabsf(railed_x_velocity), |
664 velocity_scaling * railed_y_velocity * fabsf(railed_y_velocity)), | 655 velocity_scaling * railed_y_velocity * fabsf(railed_y_velocity)), |
665 location, | 656 location, |
666 flags_, | 657 flags_, |
667 base::Time::FromDoubleT(point.last_touch_time()), | 658 base::Time::FromDoubleT(point.last_touch_time()), |
668 1 << point.touch_id())); | 659 1 << point.touch_id())); |
| 660 } else { |
| 661 gestures->push_back(CreateGestureEvent( |
| 662 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), |
| 663 location, |
| 664 flags_, |
| 665 base::Time::FromDoubleT(point.last_touch_time()), |
| 666 1 << point.touch_id())); |
669 } | 667 } |
670 } | 668 } |
671 | 669 |
672 void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point, | 670 void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point, |
673 const gfx::Point& location, | 671 const gfx::Point& location, |
674 Gestures* gestures) { | 672 Gestures* gestures) { |
675 gfx::Point current_center = bounding_box_.CenterPoint(); | 673 gfx::Point current_center = bounding_box_.CenterPoint(); |
676 int dx = current_center.x() - bounding_box_last_center_.x(); | 674 int dx = current_center.x() - bounding_box_last_center_.x(); |
677 int dy = current_center.y() - bounding_box_last_center_.y(); | 675 int dy = current_center.y() - bounding_box_last_center_.y(); |
678 if (scroll_type_ == ST_HORIZONTAL) | 676 if (scroll_type_ == ST_HORIZONTAL) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 return; | 1026 return; |
1029 | 1027 |
1030 // Since long press timer has been started, there should be a non-NULL point. | 1028 // Since long press timer has been started, there should be a non-NULL point. |
1031 const GesturePoint* point = GetPointByPointId(0); | 1029 const GesturePoint* point = GetPointByPointId(0); |
1032 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), | 1030 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), |
1033 event.GetLocation())) | 1031 event.GetLocation())) |
1034 long_press_timer_->Stop(); | 1032 long_press_timer_->Stop(); |
1035 } | 1033 } |
1036 | 1034 |
1037 } // namespace ui | 1035 } // namespace ui |
OLD | NEW |