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" |
11 #include "ui/base/gestures/gesture_point.h" | 11 #include "ui/base/gestures/gesture_point.h" |
12 #include "ui/base/gestures/gesture_recognizer.h" | 12 #include "ui/base/gestures/gesture_recognizer.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 class TouchEvent; | 15 class TouchEvent; |
16 class GestureEvent; | 16 class GestureEvent; |
17 | 17 |
18 // Gesture state. | 18 // Gesture state. |
19 enum GestureState { | 19 enum GestureState { |
20 GS_NO_GESTURE, | 20 GS_NO_GESTURE, |
21 GS_PENDING_SYNTHETIC_CLICK, | 21 GS_PENDING_SYNTHETIC_CLICK, |
22 GS_SCROLL, | 22 GS_SCROLL, |
23 GS_PINCH | 23 GS_PINCH, |
| 24 GS_THREE_FINGER_SWIPE |
24 }; | 25 }; |
25 | 26 |
26 enum ScrollType { | 27 enum ScrollType { |
27 ST_FREE, | 28 ST_FREE, |
28 ST_HORIZONTAL, | 29 ST_HORIZONTAL, |
29 ST_VERTICAL, | 30 ST_VERTICAL, |
30 }; | 31 }; |
31 | 32 |
32 // A GestureSequence recognizes gestures from touch sequences. | 33 // A GestureSequence recognizes gestures from touch sequences. |
33 class UI_EXPORT GestureSequence { | 34 class UI_EXPORT GestureSequence { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Gestures* gestures); | 93 Gestures* gestures); |
93 void AppendPinchGestureEnd(const GesturePoint& p1, | 94 void AppendPinchGestureEnd(const GesturePoint& p1, |
94 const GesturePoint& p2, | 95 const GesturePoint& p2, |
95 float scale, | 96 float scale, |
96 Gestures* gestures); | 97 Gestures* gestures); |
97 void AppendPinchGestureUpdate(const GesturePoint& p1, | 98 void AppendPinchGestureUpdate(const GesturePoint& p1, |
98 const GesturePoint& p2, | 99 const GesturePoint& p2, |
99 float scale, | 100 float scale, |
100 Gestures* gestures); | 101 Gestures* gestures); |
101 | 102 |
| 103 void AppendThreeFingerSwipeGestureEvent(const GesturePoint& p1, |
| 104 const GesturePoint& p2, |
| 105 const GesturePoint& p3, |
| 106 float x_velocity, |
| 107 float y_velocity, |
| 108 Gestures* gestures); |
| 109 |
102 void set_state(const GestureState state ) { state_ = state; } | 110 void set_state(const GestureState state ) { state_ = state; } |
103 | 111 |
104 // Various GestureTransitionFunctions for a signature. | 112 // Various GestureTransitionFunctions for a signature. |
105 // There is, 1:many mapping from GestureTransitionFunction to Signature | 113 // There is, 1:many mapping from GestureTransitionFunction to Signature |
106 // But a Signature have only one GestureTransitionFunction. | 114 // But a Signature have only one GestureTransitionFunction. |
107 bool Click(const TouchEvent& event, | 115 bool Click(const TouchEvent& event, |
108 const GesturePoint& point, | 116 const GesturePoint& point, |
109 Gestures* gestures); | 117 Gestures* gestures); |
110 bool ScrollStart(const TouchEvent& event, | 118 bool ScrollStart(const TouchEvent& event, |
111 GesturePoint& point, | 119 GesturePoint& point, |
(...skipping 15 matching lines...) Expand all Loading... |
127 Gestures* gestures); | 135 Gestures* gestures); |
128 bool PinchStart(const TouchEvent& event, | 136 bool PinchStart(const TouchEvent& event, |
129 const GesturePoint& point, | 137 const GesturePoint& point, |
130 Gestures* gestures); | 138 Gestures* gestures); |
131 bool PinchUpdate(const TouchEvent& event, | 139 bool PinchUpdate(const TouchEvent& event, |
132 const GesturePoint& point, | 140 const GesturePoint& point, |
133 Gestures* gestures); | 141 Gestures* gestures); |
134 bool PinchEnd(const TouchEvent& event, | 142 bool PinchEnd(const TouchEvent& event, |
135 const GesturePoint& point, | 143 const GesturePoint& point, |
136 Gestures* gestures); | 144 Gestures* gestures); |
| 145 bool ThreeFingerSwipeUpdate(const TouchEvent& event, |
| 146 const GesturePoint& point, |
| 147 Gestures* gestures); |
137 | 148 |
138 // Current state of gesture recognizer. | 149 // Current state of gesture recognizer. |
139 GestureState state_; | 150 GestureState state_; |
140 | 151 |
141 // ui::EventFlags. | 152 // ui::EventFlags. |
142 int flags_; | 153 int flags_; |
143 | 154 |
144 // The distance between the two points at PINCH_START. | 155 // The distance between the two points at PINCH_START. |
145 float pinch_distance_start_; | 156 float pinch_distance_start_; |
146 | 157 |
147 // This distance is updated after each PINCH_UPDATE. | 158 // This distance is updated after each PINCH_UPDATE. |
148 float pinch_distance_current_; | 159 float pinch_distance_current_; |
149 | 160 |
150 ScrollType scroll_type_; | 161 ScrollType scroll_type_; |
| 162 bool three_finger_swipe_has_fired_; |
151 scoped_ptr<base::OneShotTimer<GestureSequence> > long_press_timer_; | 163 scoped_ptr<base::OneShotTimer<GestureSequence> > long_press_timer_; |
152 | 164 |
153 GesturePoint points_[kMaxGesturePoints]; | 165 GesturePoint points_[kMaxGesturePoints]; |
154 int point_count_; | 166 int point_count_; |
155 | 167 |
156 GestureEventHelper* helper_; | 168 GestureEventHelper* helper_; |
157 | 169 |
158 DISALLOW_COPY_AND_ASSIGN(GestureSequence); | 170 DISALLOW_COPY_AND_ASSIGN(GestureSequence); |
159 }; | 171 }; |
160 | 172 |
161 } // namespace ui | 173 } // namespace ui |
162 | 174 |
163 #endif // UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ | 175 #endif // UI_BASE_GESTURES_GESTURE_SEQUENCE_H_ |
OLD | NEW |