| 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_TYPES_H_ | 5 #ifndef UI_BASE_GESTURES_GESTURE_TYPES_H_ |
| 6 #define UI_BASE_GESTURES_GESTURE_TYPES_H_ | 6 #define UI_BASE_GESTURES_GESTURE_TYPES_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 struct UI_EXPORT GestureEventDetails { | 14 struct UI_EXPORT GestureEventDetails { |
| 15 public: | 15 public: |
| 16 GestureEventDetails(EventType type, float delta_x, float delta_y); | 16 GestureEventDetails(EventType type, float delta_x, float delta_y); |
| 17 | 17 |
| 18 EventType type() const { return type_; } |
| 19 |
| 20 int touch_points() const { return touch_points_; } |
| 21 void set_touch_points(int touch_points) { touch_points_ = touch_points; } |
| 22 |
| 18 float scroll_x() const { | 23 float scroll_x() const { |
| 19 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | 24 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); |
| 20 return data.scroll.x; | 25 return data.scroll.x; |
| 21 } | 26 } |
| 22 float scroll_y() const { | 27 float scroll_y() const { |
| 23 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | 28 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); |
| 24 return data.scroll.y; | 29 return data.scroll.y; |
| 25 } | 30 } |
| 26 | 31 |
| 27 float velocity_x() const { | 32 float velocity_x() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 float radius_y() const { | 45 float radius_y() const { |
| 41 CHECK_EQ(ui::ET_GESTURE_TAP, type_); | 46 CHECK_EQ(ui::ET_GESTURE_TAP, type_); |
| 42 return data.radius.y; | 47 return data.radius.y; |
| 43 } | 48 } |
| 44 | 49 |
| 45 int touch_id() const { | 50 int touch_id() const { |
| 46 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_); | 51 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_); |
| 47 return data.touch_id; | 52 return data.touch_id; |
| 48 } | 53 } |
| 49 | 54 |
| 50 int touch_points() const { | |
| 51 DCHECK(type_ == ui::ET_GESTURE_BEGIN || type_ == ui::ET_GESTURE_END); | |
| 52 return data.touch_points; | |
| 53 } | |
| 54 | |
| 55 float scale() const { | 55 float scale() const { |
| 56 CHECK_EQ(ui::ET_GESTURE_PINCH_UPDATE, type_); | 56 CHECK_EQ(ui::ET_GESTURE_PINCH_UPDATE, type_); |
| 57 return data.scale; | 57 return data.scale; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool swipe_left() const { | 60 bool swipe_left() const { |
| 61 CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_); | 61 CHECK_EQ(ui::ET_GESTURE_MULTIFINGER_SWIPE, type_); |
| 62 return data.swipe.left; | 62 return data.swipe.left; |
| 63 } | 63 } |
| 64 bool swipe_right() const { | 64 bool swipe_right() const { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 float y; | 97 float y; |
| 98 } velocity; | 98 } velocity; |
| 99 | 99 |
| 100 struct { // TAP radius. | 100 struct { // TAP radius. |
| 101 float x; | 101 float x; |
| 102 float y; | 102 float y; |
| 103 } radius; | 103 } radius; |
| 104 | 104 |
| 105 int touch_id; // LONG_PRESS touch-id. | 105 int touch_id; // LONG_PRESS touch-id. |
| 106 | 106 |
| 107 int touch_points; // Number of active touch points for BEGIN/END. | |
| 108 | |
| 109 struct { // SWIPE direction. | 107 struct { // SWIPE direction. |
| 110 bool left; | 108 bool left; |
| 111 bool right; | 109 bool right; |
| 112 bool up; | 110 bool up; |
| 113 bool down; | 111 bool down; |
| 114 } swipe; | 112 } swipe; |
| 115 | 113 |
| 116 struct { | 114 struct { |
| 117 float delta_x; | 115 float delta_x; |
| 118 float delta_y; | 116 float delta_y; |
| 119 } generic; | 117 } generic; |
| 120 } data; | 118 } data; |
| 119 |
| 120 int touch_points_; // Number of active touch points in the gesture. |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // An abstract type to represent touch-events. The gesture-recognizer uses this | 123 // An abstract type to represent touch-events. The gesture-recognizer uses this |
| 124 // interface to communicate with the touch-events. | 124 // interface to communicate with the touch-events. |
| 125 class UI_EXPORT TouchEvent { | 125 class UI_EXPORT TouchEvent { |
| 126 public: | 126 public: |
| 127 virtual ~TouchEvent() {} | 127 virtual ~TouchEvent() {} |
| 128 | 128 |
| 129 virtual EventType GetEventType() const = 0; | 129 virtual EventType GetEventType() const = 0; |
| 130 virtual gfx::Point GetLocation() const = 0; | 130 virtual gfx::Point GetLocation() const = 0; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 // GestureEventHelper creates implementation-specific gesture events and | 181 // GestureEventHelper creates implementation-specific gesture events and |
| 182 // can dispatch them. | 182 // can dispatch them. |
| 183 class UI_EXPORT GestureEventHelper { | 183 class UI_EXPORT GestureEventHelper { |
| 184 public: | 184 public: |
| 185 virtual ~GestureEventHelper() { | 185 virtual ~GestureEventHelper() { |
| 186 } | 186 } |
| 187 | 187 |
| 188 // |flags| is ui::EventFlags. The meaning of |param_first| and |param_second| | 188 // |flags| is ui::EventFlags. The meaning of |param_first| and |param_second| |
| 189 // depends on the specific gesture type (|type|). | 189 // depends on the specific gesture type (|type|). |
| 190 virtual GestureEvent* CreateGestureEvent(EventType type, | 190 virtual GestureEvent* CreateGestureEvent(const GestureEventDetails& details, |
| 191 const gfx::Point& location, | 191 const gfx::Point& location, |
| 192 int flags, | 192 int flags, |
| 193 base::Time time, | 193 base::Time time, |
| 194 float param_first, | |
| 195 float param_second, | |
| 196 unsigned int touch_id_bitfield) = 0; | 194 unsigned int touch_id_bitfield) = 0; |
| 197 | 195 |
| 198 virtual TouchEvent* CreateTouchEvent(EventType type, | 196 virtual TouchEvent* CreateTouchEvent(EventType type, |
| 199 const gfx::Point& location, | 197 const gfx::Point& location, |
| 200 int touch_id, | 198 int touch_id, |
| 201 base::TimeDelta time_stamp) = 0; | 199 base::TimeDelta time_stamp) = 0; |
| 202 | 200 |
| 203 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; | 201 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; |
| 204 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; | 202 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; |
| 205 }; | 203 }; |
| 206 | 204 |
| 207 } // namespace ui | 205 } // namespace ui |
| 208 | 206 |
| 209 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ | 207 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ |
| OLD | NEW |