Chromium Code Reviews| 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 #include "ui/gfx/rect.h" | |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 | 14 |
| 14 struct UI_EXPORT GestureEventDetails { | 15 struct UI_EXPORT GestureEventDetails { |
| 15 public: | 16 public: |
| 16 GestureEventDetails(EventType type, float delta_x, float delta_y); | 17 GestureEventDetails(EventType type, float delta_x, float delta_y); |
| 17 | 18 |
| 18 EventType type() const { return type_; } | 19 EventType type() const { return type_; } |
| 19 | 20 |
| 20 int touch_points() const { return touch_points_; } | 21 int touch_points() const { return touch_points_; } |
| 21 void set_touch_points(int touch_points) { touch_points_ = touch_points; } | 22 void set_touch_points(int touch_points) { touch_points_ = touch_points; } |
| 22 | 23 |
| 24 const gfx::Rect& bounding_box() const { return bounding_box_; } | |
| 25 void set_bounding_box(const gfx::Rect& box) { bounding_box_ = box; } | |
| 26 | |
| 23 float scroll_x() const { | 27 float scroll_x() const { |
| 24 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | 28 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); |
| 25 return data.scroll.x; | 29 return data.scroll.x; |
| 26 } | 30 } |
| 27 float scroll_y() const { | 31 float scroll_y() const { |
| 28 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); | 32 CHECK_EQ(ui::ET_GESTURE_SCROLL_UPDATE, type_); |
| 29 return data.scroll.y; | 33 return data.scroll.y; |
| 30 } | 34 } |
| 31 | 35 |
| 32 float velocity_x() const { | 36 float velocity_x() const { |
| 33 CHECK_EQ(ui::ET_SCROLL_FLING_START, type_); | 37 CHECK_EQ(ui::ET_SCROLL_FLING_START, type_); |
| 34 return data.velocity.x; | 38 return data.velocity.x; |
| 35 } | 39 } |
| 36 float velocity_y() const { | 40 float velocity_y() const { |
| 37 CHECK_EQ(ui::ET_SCROLL_FLING_START, type_); | 41 CHECK_EQ(ui::ET_SCROLL_FLING_START, type_); |
| 38 return data.velocity.y; | 42 return data.velocity.y; |
| 39 } | 43 } |
| 40 | 44 |
| 41 float radius_x() const { | |
| 42 CHECK_EQ(ui::ET_GESTURE_TAP, type_); | |
| 43 return data.radius.x; | |
| 44 } | |
| 45 float radius_y() const { | |
| 46 CHECK_EQ(ui::ET_GESTURE_TAP, type_); | |
| 47 return data.radius.y; | |
| 48 } | |
| 49 | |
| 50 int touch_id() const { | 45 int touch_id() const { |
| 51 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_); | 46 CHECK_EQ(ui::ET_GESTURE_LONG_PRESS, type_); |
| 52 return data.touch_id; | 47 return data.touch_id; |
| 53 } | 48 } |
| 54 | 49 |
| 55 float scale() const { | 50 float scale() const { |
| 56 CHECK_EQ(ui::ET_GESTURE_PINCH_UPDATE, type_); | 51 CHECK_EQ(ui::ET_GESTURE_PINCH_UPDATE, type_); |
| 57 return data.scale; | 52 return data.scale; |
| 58 } | 53 } |
| 59 | 54 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 90 float y; | 85 float y; |
| 91 } scroll; | 86 } scroll; |
| 92 | 87 |
| 93 float scale; // PINCH scale. | 88 float scale; // PINCH scale. |
| 94 | 89 |
| 95 struct { // FLING velocity. | 90 struct { // FLING velocity. |
| 96 float x; | 91 float x; |
| 97 float y; | 92 float y; |
| 98 } velocity; | 93 } velocity; |
| 99 | 94 |
| 100 struct { // TAP radius. | |
| 101 float x; | |
| 102 float y; | |
| 103 } radius; | |
| 104 | |
| 105 int touch_id; // LONG_PRESS touch-id. | 95 int touch_id; // LONG_PRESS touch-id. |
| 106 | 96 |
| 107 struct { // SWIPE direction. | 97 struct { // SWIPE direction. |
| 108 bool left; | 98 bool left; |
| 109 bool right; | 99 bool right; |
| 110 bool up; | 100 bool up; |
| 111 bool down; | 101 bool down; |
| 112 } swipe; | 102 } swipe; |
| 113 | 103 |
| 114 struct { | 104 struct { |
| 115 float delta_x; | 105 float delta_x; |
| 116 float delta_y; | 106 float delta_y; |
| 117 } generic; | 107 } generic; |
| 118 } data; | 108 } data; |
| 119 | 109 |
| 120 int touch_points_; // Number of active touch points in the gesture. | 110 int touch_points_; // Number of active touch points in the gesture. |
| 111 | |
| 112 // Bounding box is an axis-aligned rectangle that contains all the | |
| 113 // touch-points in the gesture. | |
|
tdanderson
2012/07/23 20:21:02
Instead shouldn't this comment be "contains all th
sadrul
2012/07/23 20:34:41
Done.
| |
| 114 gfx::Rect bounding_box_; | |
| 121 }; | 115 }; |
| 122 | 116 |
| 123 // An abstract type to represent touch-events. The gesture-recognizer uses this | 117 // An abstract type to represent touch-events. The gesture-recognizer uses this |
| 124 // interface to communicate with the touch-events. | 118 // interface to communicate with the touch-events. |
| 125 class UI_EXPORT TouchEvent { | 119 class UI_EXPORT TouchEvent { |
| 126 public: | 120 public: |
| 127 virtual ~TouchEvent() {} | 121 virtual ~TouchEvent() {} |
| 128 | 122 |
| 129 virtual EventType GetEventType() const = 0; | 123 virtual EventType GetEventType() const = 0; |
| 130 virtual gfx::Point GetLocation() const = 0; | 124 virtual gfx::Point GetLocation() const = 0; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 int touch_id, | 192 int touch_id, |
| 199 base::TimeDelta time_stamp) = 0; | 193 base::TimeDelta time_stamp) = 0; |
| 200 | 194 |
| 201 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; | 195 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; |
| 202 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; | 196 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; |
| 203 }; | 197 }; |
| 204 | 198 |
| 205 } // namespace ui | 199 } // namespace ui |
| 206 | 200 |
| 207 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ | 201 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ |
| OLD | NEW |