Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: ui/base/gestures/gesture_sequence.cc

Issue 22354005: Add support for maintaining ordinal values through GestureRecognizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix to fling Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 if (scroll_type_ == ST_HORIZONTAL) 739 if (scroll_type_ == ST_HORIZONTAL)
740 railed_y_velocity = 0; 740 railed_y_velocity = 0;
741 else if (scroll_type_ == ST_VERTICAL) 741 else if (scroll_type_ == ST_VERTICAL)
742 railed_x_velocity = 0; 742 railed_x_velocity = 0;
743 743
744 if (railed_x_velocity != 0 || railed_y_velocity != 0) { 744 if (railed_x_velocity != 0 || railed_y_velocity != 0) {
745 745
746 gestures->push_back(CreateGestureEvent( 746 gestures->push_back(CreateGestureEvent(
747 GestureEventDetails(ui::ET_SCROLL_FLING_START, 747 GestureEventDetails(ui::ET_SCROLL_FLING_START,
748 CalibrateFlingVelocity(railed_x_velocity), 748 CalibrateFlingVelocity(railed_x_velocity),
749 CalibrateFlingVelocity(railed_y_velocity)), 749 CalibrateFlingVelocity(railed_y_velocity),
750 CalibrateFlingVelocity(x_velocity),
751 CalibrateFlingVelocity(y_velocity)),
750 location, 752 location,
751 flags_, 753 flags_,
752 base::Time::FromDoubleT(point.last_touch_time()), 754 base::Time::FromDoubleT(point.last_touch_time()),
753 1 << point.touch_id())); 755 1 << point.touch_id()));
754 } else { 756 } else {
755 gestures->push_back(CreateGestureEvent( 757 gestures->push_back(CreateGestureEvent(
756 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0), 758 GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0),
757 location, 759 location,
758 flags_, 760 flags_,
759 base::Time::FromDoubleT(point.last_touch_time()), 761 base::Time::FromDoubleT(point.last_touch_time()),
(...skipping 22 matching lines...) Expand all
782 d -= last_scroll_prediction_offset_; 784 d -= last_scroll_prediction_offset_;
783 last_scroll_prediction_offset_.set_x( 785 last_scroll_prediction_offset_.set_x(
784 GestureConfiguration::scroll_prediction_seconds() * point.XVelocity()); 786 GestureConfiguration::scroll_prediction_seconds() * point.XVelocity());
785 last_scroll_prediction_offset_.set_y( 787 last_scroll_prediction_offset_.set_y(
786 GestureConfiguration::scroll_prediction_seconds() * point.YVelocity()); 788 GestureConfiguration::scroll_prediction_seconds() * point.YVelocity());
787 d += last_scroll_prediction_offset_; 789 d += last_scroll_prediction_offset_;
788 location += gfx::Vector2d(last_scroll_prediction_offset_.x(), 790 location += gfx::Vector2d(last_scroll_prediction_offset_.x(),
789 last_scroll_prediction_offset_.y()); 791 last_scroll_prediction_offset_.y());
790 } 792 }
791 793
794 gfx::Vector2dF o = d;
795
792 if (scroll_type_ == ST_HORIZONTAL) 796 if (scroll_type_ == ST_HORIZONTAL)
793 d.set_y(0); 797 d.set_y(0);
794 else if (scroll_type_ == ST_VERTICAL) 798 else if (scroll_type_ == ST_VERTICAL)
795 d.set_x(0); 799 d.set_x(0);
796 if (d.IsZero()) 800 if (d.IsZero())
797 return; 801 return;
798 802
799 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, d.x(), d.y()); 803 GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE,
804 d.x(), d.y(), o.x(), o.y());
800 details.SetScrollVelocity( 805 details.SetScrollVelocity(
801 scroll_type_ == ST_VERTICAL ? 0 : point.XVelocity(), 806 scroll_type_ == ST_VERTICAL ? 0 : point.XVelocity(),
802 scroll_type_ == ST_HORIZONTAL ? 0 : point.YVelocity()); 807 scroll_type_ == ST_HORIZONTAL ? 0 : point.YVelocity(),
808 point.XVelocity(),
809 point.YVelocity());
803 gestures->push_back(CreateGestureEvent( 810 gestures->push_back(CreateGestureEvent(
804 details, 811 details,
805 location, 812 location,
806 flags_, 813 flags_,
807 base::Time::FromDoubleT(point.last_touch_time()), 814 base::Time::FromDoubleT(point.last_touch_time()),
808 ComputeTouchBitmask(points_))); 815 ComputeTouchBitmask(points_)));
809 } 816 }
810 817
811 void GestureSequence::AppendPinchGestureBegin(const GesturePoint& p1, 818 void GestureSequence::AppendPinchGestureBegin(const GesturePoint& p1,
812 const GesturePoint& p2, 819 const GesturePoint& p2,
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 return; 1177 return;
1171 1178
1172 // Since long press timer has been started, there should be a non-NULL point. 1179 // Since long press timer has been started, there should be a non-NULL point.
1173 const GesturePoint* point = GetPointByPointId(0); 1180 const GesturePoint* point = GetPointByPointId(0);
1174 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(), 1181 if (!ui::gestures::IsInsideManhattanSquare(point->first_touch_position(),
1175 event.location())) 1182 event.location()))
1176 GetLongPressTimer()->Stop(); 1183 GetLongPressTimer()->Stop();
1177 } 1184 }
1178 1185
1179 } // namespace ui 1186 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698