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 #include "ui/gfx/rect.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
| 15 class GestureEvent; |
15 class TouchEvent; | 16 class TouchEvent; |
16 | 17 |
17 struct UI_EXPORT GestureEventDetails { | 18 struct UI_EXPORT GestureEventDetails { |
18 public: | 19 public: |
19 GestureEventDetails(EventType type, float delta_x, float delta_y); | 20 GestureEventDetails(EventType type, float delta_x, float delta_y); |
20 | 21 |
21 EventType type() const { return type_; } | 22 EventType type() const { return type_; } |
22 | 23 |
23 int touch_points() const { return touch_points_; } | 24 int touch_points() const { return touch_points_; } |
24 void set_touch_points(int touch_points) { touch_points_ = touch_points; } | 25 void set_touch_points(int touch_points) { touch_points_ = touch_points; } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } generic; | 109 } generic; |
109 } data; | 110 } data; |
110 | 111 |
111 int touch_points_; // Number of active touch points in the gesture. | 112 int touch_points_; // Number of active touch points in the gesture. |
112 | 113 |
113 // Bounding box is an axis-aligned rectangle that contains all the | 114 // Bounding box is an axis-aligned rectangle that contains all the |
114 // enclosing rectangles of the touch-points in the gesture. | 115 // enclosing rectangles of the touch-points in the gesture. |
115 gfx::Rect bounding_box_; | 116 gfx::Rect bounding_box_; |
116 }; | 117 }; |
117 | 118 |
118 // An abstract type to represent gesture-events. | |
119 class UI_EXPORT GestureEvent { | |
120 public: | |
121 virtual ~GestureEvent() {} | |
122 | |
123 // A gesture event can have multiple touches. This function should return the | |
124 // lowest ID of the touches in this gesture. | |
125 virtual int GetLowestTouchId() const = 0; | |
126 | |
127 // A helper function used in several (all) derived classes. | |
128 // Returns lowest set bit, or -1 if no bits are set. | |
129 static int LowestBit(unsigned int bitfield) { | |
130 int i = -1; | |
131 // Find the index of the least significant 1 bit | |
132 while (bitfield && (!((1 << ++i) & bitfield))); | |
133 return i; | |
134 } | |
135 }; | |
136 | |
137 // An abstract type for consumers of gesture-events created by the | 119 // An abstract type for consumers of gesture-events created by the |
138 // gesture-recognizer. | 120 // gesture-recognizer. |
139 class UI_EXPORT GestureConsumer { | 121 class UI_EXPORT GestureConsumer { |
140 public: | 122 public: |
141 GestureConsumer() | 123 GestureConsumer() |
142 : ignores_events_(false) { | 124 : ignores_events_(false) { |
143 } | 125 } |
144 | 126 |
145 explicit GestureConsumer(bool ignores_events) | 127 explicit GestureConsumer(bool ignores_events) |
146 : ignores_events_(ignores_events) { | 128 : ignores_events_(ignores_events) { |
(...skipping 29 matching lines...) Expand all Loading... |
176 int touch_id, | 158 int touch_id, |
177 base::TimeDelta time_stamp) = 0; | 159 base::TimeDelta time_stamp) = 0; |
178 | 160 |
179 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; | 161 virtual bool DispatchLongPressGestureEvent(GestureEvent* event) = 0; |
180 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; | 162 virtual bool DispatchCancelTouchEvent(TouchEvent* event) = 0; |
181 }; | 163 }; |
182 | 164 |
183 } // namespace ui | 165 } // namespace ui |
184 | 166 |
185 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ | 167 #endif // UI_BASE_GESTURES_GESTURE_TYPES_H_ |
OLD | NEW |