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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 case GST_PINCH_THIRD_PRESSED: | 262 case GST_PINCH_THIRD_PRESSED: |
263 three_finger_swipe_has_fired_ = false; | 263 three_finger_swipe_has_fired_ = false; |
264 set_state(GS_THREE_FINGER_SWIPE); | 264 set_state(GS_THREE_FINGER_SWIPE); |
265 break; | 265 break; |
266 case GST_THREE_FINGER_SWIPE_FIRST_RELEASED: | 266 case GST_THREE_FINGER_SWIPE_FIRST_RELEASED: |
267 case GST_THREE_FINGER_SWIPE_SECOND_RELEASED: | 267 case GST_THREE_FINGER_SWIPE_SECOND_RELEASED: |
268 case GST_THREE_FINGER_SWIPE_THIRD_RELEASED: | 268 case GST_THREE_FINGER_SWIPE_THIRD_RELEASED: |
269 case GST_THREE_FINGER_SWIPE_FIRST_CANCELLED: | 269 case GST_THREE_FINGER_SWIPE_FIRST_CANCELLED: |
270 case GST_THREE_FINGER_SWIPE_SECOND_CANCELLED: | 270 case GST_THREE_FINGER_SWIPE_SECOND_CANCELLED: |
271 case GST_THREE_FINGER_SWIPE_THIRD_CANCELLED: | 271 case GST_THREE_FINGER_SWIPE_THIRD_CANCELLED: |
| 272 GetPointByPointId(0)->ResetVelocity(); |
| 273 GetPointByPointId(1)->ResetVelocity(); |
| 274 GetPointByPointId(2)->ResetVelocity(); |
272 set_state(GS_PINCH); | 275 set_state(GS_PINCH); |
273 break; | 276 break; |
274 case GST_THREE_FINGER_SWIPE_FIRST_MOVED: | 277 case GST_THREE_FINGER_SWIPE_FIRST_MOVED: |
275 case GST_THREE_FINGER_SWIPE_SECOND_MOVED: | 278 case GST_THREE_FINGER_SWIPE_SECOND_MOVED: |
276 case GST_THREE_FINGER_SWIPE_THIRD_MOVED: | 279 case GST_THREE_FINGER_SWIPE_THIRD_MOVED: |
277 if (!three_finger_swipe_has_fired_) { | 280 if (!three_finger_swipe_has_fired_) { |
278 ThreeFingerSwipeUpdate(event, point, gestures.get()); | 281 ThreeFingerSwipeUpdate(event, point, gestures.get()); |
279 GetPointByPointId(0)->UpdateForScroll(); | 282 GetPointByPointId(0)->UpdateForScroll(); |
280 GetPointByPointId(1)->UpdateForScroll(); | 283 GetPointByPointId(1)->UpdateForScroll(); |
281 GetPointByPointId(2)->UpdateForScroll(); | 284 GetPointByPointId(2)->UpdateForScroll(); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 distance / pinch_distance_current_, gestures); | 647 distance / pinch_distance_current_, gestures); |
645 pinch_distance_current_ = distance; | 648 pinch_distance_current_ = distance; |
646 } | 649 } |
647 return true; | 650 return true; |
648 } | 651 } |
649 | 652 |
650 bool GestureSequence::PinchEnd(const TouchEvent& event, | 653 bool GestureSequence::PinchEnd(const TouchEvent& event, |
651 const GesturePoint& point, Gestures* gestures) { | 654 const GesturePoint& point, Gestures* gestures) { |
652 DCHECK(state_ == GS_PINCH); | 655 DCHECK(state_ == GS_PINCH); |
653 | 656 |
654 const GesturePoint* point1 = GetPointByPointId(0); | 657 GesturePoint* point1 = GetPointByPointId(0); |
655 const GesturePoint* point2 = GetPointByPointId(1); | 658 GesturePoint* point2 = GetPointByPointId(1); |
656 | 659 |
657 float distance = point1->Distance(*point2); | 660 float distance = point1->Distance(*point2); |
658 AppendPinchGestureEnd(*point1, *point2, | 661 AppendPinchGestureEnd(*point1, *point2, |
659 distance / pinch_distance_start_, gestures); | 662 distance / pinch_distance_start_, gestures); |
660 | 663 |
| 664 point1->ResetVelocity(); |
| 665 point2->ResetVelocity(); |
| 666 |
661 pinch_distance_start_ = 0; | 667 pinch_distance_start_ = 0; |
662 pinch_distance_current_ = 0; | 668 pinch_distance_current_ = 0; |
663 return true; | 669 return true; |
664 } | 670 } |
665 | 671 |
666 bool GestureSequence::ThreeFingerSwipeUpdate(const TouchEvent& event, | 672 bool GestureSequence::ThreeFingerSwipeUpdate(const TouchEvent& event, |
667 const GesturePoint& point, Gestures* gestures) { | 673 const GesturePoint& point, Gestures* gestures) { |
668 DCHECK(state_ == GS_THREE_FINGER_SWIPE); | 674 DCHECK(state_ == GS_THREE_FINGER_SWIPE); |
669 | 675 |
670 GesturePoint* point1 = GetPointByPointId(0); | 676 GesturePoint* point1 = GetPointByPointId(0); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 vy3 * sign < min_velocity) | 718 vy3 * sign < min_velocity) |
713 return false; | 719 return false; |
714 AppendThreeFingerSwipeGestureEvent(*point1, *point2, *point3, | 720 AppendThreeFingerSwipeGestureEvent(*point1, *point2, *point3, |
715 0, sign, gestures); | 721 0, sign, gestures); |
716 } | 722 } |
717 three_finger_swipe_has_fired_ = true; | 723 three_finger_swipe_has_fired_ = true; |
718 return true; | 724 return true; |
719 } | 725 } |
720 | 726 |
721 } // namespace ui | 727 } // namespace ui |
OLD | NEW |