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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 TouchEvent(const TouchEvent& model, T* source, T* target) | 203 TouchEvent(const TouchEvent& model, T* source, T* target) |
204 : LocatedEvent(model, source, target), | 204 : LocatedEvent(model, source, target), |
205 touch_id_(model.touch_id_), | 205 touch_id_(model.touch_id_), |
206 radius_x_(model.radius_x_), | 206 radius_x_(model.radius_x_), |
207 radius_y_(model.radius_y_), | 207 radius_y_(model.radius_y_), |
208 rotation_angle_(model.rotation_angle_), | 208 rotation_angle_(model.rotation_angle_), |
209 force_(model.force_) { | 209 force_(model.force_) { |
210 } | 210 } |
211 | 211 |
212 TouchEvent(EventType type, | 212 TouchEvent(EventType type, |
213 const gfx::Point& root_location, | 213 const gfx::Point& root_location, |
214 int touch_id, | 214 int touch_id, |
215 base::TimeDelta time_stamp); | 215 base::TimeDelta time_stamp); |
216 | 216 |
217 virtual ~TouchEvent(); | 217 virtual ~TouchEvent(); |
218 | 218 |
219 int touch_id() const { return touch_id_; } | 219 int touch_id() const { return touch_id_; } |
220 float radius_x() const { return radius_x_; } | 220 float radius_x() const { return radius_x_; } |
221 float radius_y() const { return radius_y_; } | 221 float radius_y() const { return radius_y_; } |
222 float rotation_angle() const { return rotation_angle_; } | 222 float rotation_angle() const { return rotation_angle_; } |
223 float force() const { return force_; } | 223 float force() const { return force_; } |
224 | 224 |
225 // Used for unit tests. | 225 // Used for unit tests. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 float x_offset() const { return x_offset_; } | 365 float x_offset() const { return x_offset_; } |
366 float y_offset() const { return y_offset_; } | 366 float y_offset() const { return y_offset_; } |
367 | 367 |
368 private: | 368 private: |
369 float x_offset_; | 369 float x_offset_; |
370 float y_offset_; | 370 float y_offset_; |
371 | 371 |
372 DISALLOW_COPY_AND_ASSIGN(ScrollEvent); | 372 DISALLOW_COPY_AND_ASSIGN(ScrollEvent); |
373 }; | 373 }; |
374 | 374 |
375 // TODO(beng): rename to GestureEvent after conversion is complete. | 375 class UI_EXPORT GestureEvent : public LocatedEvent { |
376 class UI_EXPORT GestureEventImpl : public LocatedEvent, | |
377 public GestureEvent { | |
378 public: | 376 public: |
379 GestureEventImpl(EventType type, | 377 GestureEvent(EventType type, |
380 int x, | 378 int x, |
381 int y, | 379 int y, |
382 int flags, | 380 int flags, |
383 base::Time time_stamp, | 381 base::Time time_stamp, |
384 const GestureEventDetails& details, | 382 const GestureEventDetails& details, |
385 unsigned int touch_ids_bitfield); | 383 unsigned int touch_ids_bitfield); |
386 | 384 |
387 // Create a new GestureEventImpl which is identical to the provided model. | 385 // Create a new GestureEvent which is identical to the provided model. |
388 // If source / target windows are provided, the model location will be | 386 // If source / target windows are provided, the model location will be |
389 // converted from |source| coordinate system to |target| coordinate system. | 387 // converted from |source| coordinate system to |target| coordinate system. |
390 template <typename T> | 388 template <typename T> |
391 GestureEventImpl(const GestureEventImpl& model, T* source, T* target) | 389 GestureEvent(const GestureEvent& model, T* source, T* target) |
392 : LocatedEvent(model, source, target), | 390 : LocatedEvent(model, source, target), |
393 details_(model.details_), | 391 details_(model.details_), |
394 touch_ids_bitfield_(model.touch_ids_bitfield_) { | 392 touch_ids_bitfield_(model.touch_ids_bitfield_) { |
395 } | 393 } |
396 | 394 |
397 virtual ~GestureEventImpl(); | 395 virtual ~GestureEvent(); |
398 | 396 |
399 const GestureEventDetails& details() const { return details_; } | 397 const GestureEventDetails& details() const { return details_; } |
400 | 398 |
401 // Returns the lowest touch-id of any of the touches which make up this | 399 // Returns the lowest touch-id of any of the touches which make up this |
402 // gesture. | 400 // gesture. If there are no touches associated with this gesture, returns -1. |
403 // If there are no touches associated with this gesture, returns -1. | 401 int GetLowestTouchId() const; |
404 virtual int GetLowestTouchId() const OVERRIDE; | |
405 | 402 |
406 private: | 403 private: |
407 GestureEventDetails details_; | 404 GestureEventDetails details_; |
408 | 405 |
409 // The set of indices of ones in the binary representation of | 406 // The set of indices of ones in the binary representation of |
410 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 407 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
411 // This value is stored as a bitfield because the number of touch ids varies, | 408 // This value is stored as a bitfield because the number of touch ids varies, |
412 // but we currently don't need more than 32 touches at a time. | 409 // but we currently don't need more than 32 touches at a time. |
413 const unsigned int touch_ids_bitfield_; | 410 const unsigned int touch_ids_bitfield_; |
414 | 411 |
415 DISALLOW_COPY_AND_ASSIGN(GestureEventImpl); | 412 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
416 }; | 413 }; |
417 | 414 |
418 } // namespace ui | 415 } // namespace ui |
419 | 416 |
420 #endif // UI_BASE_EVENT_H_ | 417 #endif // UI_BASE_EVENT_H_ |
OLD | NEW |