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_EVENT_H_ | 5 #ifndef UI_BASE_EVENT_H_ |
6 #define UI_BASE_EVENT_H_ | 6 #define UI_BASE_EVENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 explicit MouseEvent(const MouseEvent& model); | 185 explicit MouseEvent(const MouseEvent& model); |
186 | 186 |
187 gfx::Point root_location_; | 187 gfx::Point root_location_; |
188 | 188 |
189 static MouseEvent* last_click_event_; | 189 static MouseEvent* last_click_event_; |
190 // Returns the repeat count based on the previous mouse click, if it is | 190 // Returns the repeat count based on the previous mouse click, if it is |
191 // recent enough and within a small enough distance. | 191 // recent enough and within a small enough distance. |
192 static int GetRepeatCount(const MouseEvent& click_event); | 192 static int GetRepeatCount(const MouseEvent& click_event); |
193 }; | 193 }; |
194 | 194 |
195 // TODO(beng): rename to TouchEvent after conversion is complete. | 195 class UI_EXPORT TouchEvent : public LocatedEvent { |
196 class UI_EXPORT TouchEventImpl : public LocatedEvent, | |
197 public TouchEvent { | |
198 public: | 196 public: |
199 explicit TouchEventImpl(const base::NativeEvent& native_event); | 197 explicit TouchEvent(const base::NativeEvent& native_event); |
200 | 198 |
201 // Create a new TouchEventImpl which is identical to the provided model. | 199 // Create a new TouchEvent which is identical to the provided model. |
202 // If source / target windows are provided, the model location will be | 200 // If source / target windows are provided, the model location will be |
203 // converted from |source| coordinate system to |target| coordinate system. | 201 // converted from |source| coordinate system to |target| coordinate system. |
204 template <class T> | 202 template <class T> |
205 TouchEventImpl(const TouchEventImpl& model, T* source, T* target) | 203 TouchEvent(const TouchEvent& model, T* source, T* target) |
206 : LocatedEvent(model, source, target), | 204 : LocatedEvent(model, source, target), |
207 touch_id_(model.touch_id_), | 205 touch_id_(model.touch_id_), |
208 radius_x_(model.radius_x_), | 206 radius_x_(model.radius_x_), |
209 radius_y_(model.radius_y_), | 207 radius_y_(model.radius_y_), |
210 rotation_angle_(model.rotation_angle_), | 208 rotation_angle_(model.rotation_angle_), |
211 force_(model.force_) { | 209 force_(model.force_) { |
212 } | 210 } |
213 | 211 |
214 TouchEventImpl(EventType type, | 212 TouchEvent(EventType type, |
215 const gfx::Point& root_location, | 213 const gfx::Point& root_location, |
216 int touch_id, | 214 int touch_id, |
217 base::TimeDelta time_stamp); | 215 base::TimeDelta time_stamp); |
218 | 216 |
219 virtual ~TouchEventImpl(); | 217 virtual ~TouchEvent(); |
220 | 218 |
221 int touch_id() const { return touch_id_; } | 219 int touch_id() const { return touch_id_; } |
222 float radius_x() const { return radius_x_; } | 220 float radius_x() const { return radius_x_; } |
223 float radius_y() const { return radius_y_; } | 221 float radius_y() const { return radius_y_; } |
224 float rotation_angle() const { return rotation_angle_; } | 222 float rotation_angle() const { return rotation_angle_; } |
225 float force() const { return force_; } | 223 float force() const { return force_; } |
226 | 224 |
227 // Used for unit tests. | 225 // Used for unit tests. |
228 void set_radius_x(const float r) { radius_x_ = r; } | 226 void set_radius_x(const float r) { radius_x_ = r; } |
229 void set_radius_y(const float r) { radius_y_ = r; } | 227 void set_radius_y(const float r) { radius_y_ = r; } |
230 | 228 |
231 // Overridden from LocatedEvent. | 229 // Overridden from LocatedEvent. |
232 virtual void UpdateForRootTransform(const Transform& root_transform) OVERRIDE; | 230 virtual void UpdateForRootTransform(const Transform& root_transform) OVERRIDE; |
233 | 231 |
234 // Overridden from TouchEvent. | 232 protected: |
235 virtual EventType GetEventType() const OVERRIDE; | 233 void set_radius(float radius_x, float radius_y) { |
236 virtual gfx::Point GetLocation() const OVERRIDE; | 234 radius_x_ = radius_x; |
237 virtual int GetTouchId() const OVERRIDE; | 235 radius_y_ = radius_y; |
238 virtual int GetEventFlags() const OVERRIDE; | 236 } |
239 virtual base::TimeDelta GetTimestamp() const OVERRIDE; | 237 |
240 virtual float RadiusX() const OVERRIDE; | 238 void set_rotation_angle(float rotation_angle) { |
241 virtual float RadiusY() const OVERRIDE; | 239 rotation_angle_ = rotation_angle; |
242 virtual float RotationAngle() const OVERRIDE; | 240 } |
243 virtual float Force() const OVERRIDE; | 241 |
| 242 void set_force(float force) { force_ = force; } |
| 243 |
| 244 protected: |
| 245 void set_radius(float radius_x, float radius_y) { |
| 246 radius_x_ = radius_x; |
| 247 radius_y_ = radius_y; |
| 248 } |
| 249 |
| 250 void set_rotation_angle(float rotation_angle) { |
| 251 rotation_angle_ = rotation_angle; |
| 252 } |
| 253 |
| 254 void set_force(float force) { force_ = force; } |
244 | 255 |
245 private: | 256 private: |
246 // The identity (typically finger) of the touch starting at 0 and incrementing | 257 // The identity (typically finger) of the touch starting at 0 and incrementing |
247 // for each separable additional touch that the hardware can detect. | 258 // for each separable additional touch that the hardware can detect. |
248 const int touch_id_; | 259 const int touch_id_; |
249 | 260 |
250 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. | 261 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. |
251 float radius_x_; | 262 float radius_x_; |
252 | 263 |
253 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 264 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
254 float radius_y_; | 265 float radius_y_; |
255 | 266 |
256 // Angle of the major axis away from the X axis. Default 0.0. | 267 // Angle of the major axis away from the X axis. Default 0.0. |
257 const float rotation_angle_; | 268 float rotation_angle_; |
258 | 269 |
259 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 270 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
260 const float force_; | 271 float force_; |
261 | 272 |
262 DISALLOW_COPY_AND_ASSIGN(TouchEventImpl); | 273 DISALLOW_COPY_AND_ASSIGN(TouchEvent); |
263 }; | 274 }; |
264 | 275 |
265 class UI_EXPORT KeyEvent : public Event { | 276 class UI_EXPORT KeyEvent : public Event { |
266 public: | 277 public: |
267 KeyEvent(const base::NativeEvent& native_event, bool is_char); | 278 KeyEvent(const base::NativeEvent& native_event, bool is_char); |
268 | 279 |
269 // Used for synthetic events in testing. | 280 // Used for synthetic events in testing. |
270 KeyEvent(EventType type, KeyboardCode key_code, int flags); | 281 KeyEvent(EventType type, KeyboardCode key_code, int flags); |
271 | 282 |
272 // These setters allow an I18N virtual keyboard to fabricate a keyboard event | 283 // These setters allow an I18N virtual keyboard to fabricate a keyboard event |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // This value is stored as a bitfield because the number of touch ids varies, | 423 // This value is stored as a bitfield because the number of touch ids varies, |
413 // but we currently don't need more than 32 touches at a time. | 424 // but we currently don't need more than 32 touches at a time. |
414 const unsigned int touch_ids_bitfield_; | 425 const unsigned int touch_ids_bitfield_; |
415 | 426 |
416 DISALLOW_COPY_AND_ASSIGN(GestureEventImpl); | 427 DISALLOW_COPY_AND_ASSIGN(GestureEventImpl); |
417 }; | 428 }; |
418 | 429 |
419 } // namespace ui | 430 } // namespace ui |
420 | 431 |
421 #endif // UI_BASE_EVENT_H_ | 432 #endif // UI_BASE_EVENT_H_ |
OLD | NEW |