| 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 #ifndef UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ | 5 #ifndef UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ |
| 6 #define UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ | 6 #define UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/timer.h" | 9 #include "base/timer.h" |
| 10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 enum ScrollType { | 27 enum ScrollType { |
| 28 ST_FREE, | 28 ST_FREE, |
| 29 ST_HORIZONTAL, | 29 ST_HORIZONTAL, |
| 30 ST_VERTICAL, | 30 ST_VERTICAL, |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // A GestureSequence recognizes gestures from touch sequences. | 33 // A GestureSequence recognizes gestures from touch sequences. |
| 34 class UI_EXPORT GestureSequence { | 34 class UI_EXPORT GestureSequence { |
| 35 public: | 35 public: |
| 36 // Maximum number of points in a single gesture. |
| 37 static const int kMaxGesturePoints = 12; |
| 38 |
| 36 explicit GestureSequence(GestureEventHelper* consumer); | 39 explicit GestureSequence(GestureEventHelper* consumer); |
| 37 virtual ~GestureSequence(); | 40 virtual ~GestureSequence(); |
| 38 | 41 |
| 39 typedef GestureRecognizer::Gestures Gestures; | 42 typedef GestureRecognizer::Gestures Gestures; |
| 40 | 43 |
| 41 // Invoked for each touch event that could contribute to the current gesture. | 44 // Invoked for each touch event that could contribute to the current gesture. |
| 42 // Returns list of zero or more GestureEvents identified after processing | 45 // Returns list of zero or more GestureEvents identified after processing |
| 43 // TouchEvent. | 46 // TouchEvent. |
| 44 // Caller would be responsible for freeing up Gestures. | 47 // Caller would be responsible for freeing up Gestures. |
| 45 virtual Gestures* ProcessTouchEventForGesture(const TouchEvent& event, | 48 virtual Gestures* ProcessTouchEventForGesture(const TouchEvent& event, |
| 46 ui::TouchStatus status); | 49 ui::TouchStatus status); |
| 47 const GesturePoint* points() const { return points_; } | 50 const GesturePoint* points() const { return points_; } |
| 48 int point_count() const { return point_count_; } | 51 int point_count() const { return point_count_; } |
| 49 | 52 |
| 50 // Maximum number of points in a single gesture. | |
| 51 static const int kMaxGesturePoints = 12; | |
| 52 | |
| 53 protected: | 53 protected: |
| 54 virtual base::OneShotTimer<GestureSequence>* CreateTimer(); | 54 virtual base::OneShotTimer<GestureSequence>* CreateTimer(); |
| 55 base::OneShotTimer<GestureSequence>* long_press_timer() { | 55 base::OneShotTimer<GestureSequence>* long_press_timer() { |
| 56 return long_press_timer_.get(); | 56 return long_press_timer_.get(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 void Reset(); | 60 void Reset(); |
| 61 | 61 |
| 62 // Recreates the axis-aligned bounding box that contains all the touch-points | 62 // Recreates the axis-aligned bounding box that contains all the touch-points |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 float scale, | 103 float scale, |
| 104 Gestures* gestures); | 104 Gestures* gestures); |
| 105 void AppendPinchGestureUpdate(const GesturePoint& point, | 105 void AppendPinchGestureUpdate(const GesturePoint& point, |
| 106 float scale, | 106 float scale, |
| 107 Gestures* gestures); | 107 Gestures* gestures); |
| 108 void AppendSwipeGesture(const GesturePoint& point, | 108 void AppendSwipeGesture(const GesturePoint& point, |
| 109 int swipe_x, | 109 int swipe_x, |
| 110 int swipe_y, | 110 int swipe_y, |
| 111 Gestures* gestures); | 111 Gestures* gestures); |
| 112 | 112 |
| 113 void set_state(const GestureState state ) { state_ = state; } | 113 void set_state(const GestureState state) { state_ = state; } |
| 114 | 114 |
| 115 // Various GestureTransitionFunctions for a signature. | 115 // Various GestureTransitionFunctions for a signature. |
| 116 // There is, 1:many mapping from GestureTransitionFunction to Signature | 116 // There is, 1:many mapping from GestureTransitionFunction to Signature |
| 117 // But a Signature have only one GestureTransitionFunction. | 117 // But a Signature have only one GestureTransitionFunction. |
| 118 bool Click(const TouchEvent& event, | 118 bool Click(const TouchEvent& event, |
| 119 const GesturePoint& point, | 119 const GesturePoint& point, |
| 120 Gestures* gestures); | 120 Gestures* gestures); |
| 121 bool ScrollStart(const TouchEvent& event, | 121 bool ScrollStart(const TouchEvent& event, |
| 122 GesturePoint& point, | 122 GesturePoint& point, |
| 123 Gestures* gestures); | 123 Gestures* gestures); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 int point_count_; | 177 int point_count_; |
| 178 | 178 |
| 179 GestureEventHelper* helper_; | 179 GestureEventHelper* helper_; |
| 180 | 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(GestureSequence); | 181 DISALLOW_COPY_AND_ASSIGN(GestureSequence); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } // namespace ui | 184 } // namespace ui |
| 185 | 185 |
| 186 #endif // UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ | 186 #endif // UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ |
| OLD | NEW |