diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 07:56:51 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-30 07:56:51 +0000 |
commit | 8a21fcbe26507c0c628157778d69e80a7236007f (patch) | |
tree | 61c98e6ddc22e16fbb4b5f6d2bba8de11cd8dd4a /ui/base/gestures/gesture_sequence.h | |
parent | 97c747b5e54da43db3fb8bf49882f34fb565610e (diff) | |
download | chromium_src-8a21fcbe26507c0c628157778d69e80a7236007f.zip chromium_src-8a21fcbe26507c0c628157778d69e80a7236007f.tar.gz chromium_src-8a21fcbe26507c0c628157778d69e80a7236007f.tar.bz2 |
Revert 139473 - Revert 139398 - gesture recognizer: Allow multi-finger pinch/scroll gestures.
Instead of having specific X-finger gestures (e.g. three-finger swipe,
two-finger pinch), add support for gestures with a variable number of fingers
(e.g. two-finger pinch and three-finger pinch etc.)
BUG=121140
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10137010
TBR=sadrul@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10449065
TBR=kinuko@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10454068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/gestures/gesture_sequence.h')
-rw-r--r-- | ui/base/gestures/gesture_sequence.h | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/ui/base/gestures/gesture_sequence.h b/ui/base/gestures/gesture_sequence.h index e8d7aab..b8a9a02 100644 --- a/ui/base/gestures/gesture_sequence.h +++ b/ui/base/gestures/gesture_sequence.h @@ -10,6 +10,7 @@ #include "ui/base/events.h" #include "ui/base/gestures/gesture_point.h" #include "ui/base/gestures/gesture_recognizer.h" +#include "ui/gfx/rect.h" namespace ui { class TouchEvent; @@ -21,7 +22,6 @@ enum GestureState { GS_PENDING_SYNTHETIC_CLICK, GS_SCROLL, GS_PINCH, - GS_THREE_FINGER_SWIPE }; enum ScrollType { @@ -59,6 +59,12 @@ class UI_EXPORT GestureSequence { private: void Reset(); + // Recreates the axis-aligned bounding box that contains all the touch-points + // at their most recent position. + void RecreateBoundingBox(); + + void ResetVelocities(); + GesturePoint& GesturePointForEvent(const TouchEvent& event); // Do a linear scan through points_ to find the GesturePoint @@ -69,6 +75,7 @@ class UI_EXPORT GestureSequence { // Tap gestures. void AppendTapDownGestureEvent(const GesturePoint& point, Gestures* gestures); + void AppendTapUpGestureEvent(const GesturePoint& point, Gestures* gestures); void AppendClickGestureEvent(const GesturePoint& point, Gestures* gestures); void AppendDoubleClickGestureEvent(const GesturePoint& point, Gestures* gestures); @@ -95,17 +102,13 @@ class UI_EXPORT GestureSequence { const GesturePoint& p2, float scale, Gestures* gestures); - void AppendPinchGestureUpdate(const GesturePoint& p1, - const GesturePoint& p2, + void AppendPinchGestureUpdate(const GesturePoint& point, float scale, Gestures* gestures); - - void AppendThreeFingerSwipeGestureEvent(const GesturePoint& p1, - const GesturePoint& p2, - const GesturePoint& p3, - float x_velocity, - float y_velocity, - Gestures* gestures); + void AppendSwipeGesture(const GesturePoint& point, + int swipe_x, + int swipe_y, + Gestures* gestures); void set_state(const GestureState state ) { state_ = state; } @@ -116,11 +119,11 @@ class UI_EXPORT GestureSequence { const GesturePoint& point, Gestures* gestures); bool ScrollStart(const TouchEvent& event, - GesturePoint& point, - Gestures* gestures); + GesturePoint& point, + Gestures* gestures); void BreakRailScroll(const TouchEvent& event, - GesturePoint& point, - Gestures* gestures); + GesturePoint& point, + Gestures* gestures); bool ScrollUpdate(const TouchEvent& event, const GesturePoint& point, Gestures* gestures); @@ -142,9 +145,9 @@ class UI_EXPORT GestureSequence { bool PinchEnd(const TouchEvent& event, const GesturePoint& point, Gestures* gestures); - bool ThreeFingerSwipeUpdate(const TouchEvent& event, - const GesturePoint& point, - Gestures* gestures); + bool MaybeSwipe(const TouchEvent& event, + const GesturePoint& point, + Gestures* gestures); // Current state of gesture recognizer. GestureState state_; @@ -152,6 +155,15 @@ class UI_EXPORT GestureSequence { // ui::EventFlags. int flags_; + // We maintain the smallest axis-aligned rectangle that contains all the + // current touch-points. The 'distance' represents the diagonal distance. + // This box is updated after every touch-event. + gfx::Rect bounding_box_; + gfx::Point bounding_box_last_center_; + + // For pinch, the 'distance' represents the diagonal distance of + // |bounding_box_|. + // The distance between the two points at PINCH_START. float pinch_distance_start_; @@ -159,7 +171,6 @@ class UI_EXPORT GestureSequence { float pinch_distance_current_; ScrollType scroll_type_; - bool three_finger_swipe_has_fired_; scoped_ptr<base::OneShotTimer<GestureSequence> > long_press_timer_; GesturePoint points_[kMaxGesturePoints]; |