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_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
| 6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 // Create a new TouchEvent which is identical to the provided model. | 429 // Create a new TouchEvent which is identical to the provided model. |
| 430 // If source / target windows are provided, the model location will be | 430 // If source / target windows are provided, the model location will be |
| 431 // converted from |source| coordinate system to |target| coordinate system. | 431 // converted from |source| coordinate system to |target| coordinate system. |
| 432 template <class T> | 432 template <class T> |
| 433 TouchEvent(const TouchEvent& model, T* source, T* target) | 433 TouchEvent(const TouchEvent& model, T* source, T* target) |
| 434 : LocatedEvent(model, source, target), | 434 : LocatedEvent(model, source, target), |
| 435 touch_id_(model.touch_id_), | 435 touch_id_(model.touch_id_), |
| 436 radius_x_(model.radius_x_), | 436 radius_x_(model.radius_x_), |
| 437 radius_y_(model.radius_y_), | 437 radius_y_(model.radius_y_), |
| 438 rotation_angle_(model.rotation_angle_), | 438 rotation_angle_(model.rotation_angle_), |
| 439 force_(model.force_) { | 439 force_(model.force_), |
| 440 source_device_id_(model.source_device_id_) { | |
| 440 } | 441 } |
| 441 | 442 |
| 442 TouchEvent(EventType type, | 443 TouchEvent(EventType type, |
| 443 const gfx::Point& root_location, | 444 const gfx::Point& root_location, |
| 444 int touch_id, | 445 int touch_id, |
| 445 base::TimeDelta time_stamp); | 446 base::TimeDelta time_stamp); |
| 446 | 447 |
| 447 TouchEvent(EventType type, | 448 TouchEvent(EventType type, |
| 448 const gfx::Point& location, | 449 const gfx::Point& location, |
| 449 int flags, | 450 int flags, |
| 450 int touch_id, | 451 int touch_id, |
| 451 base::TimeDelta timestamp, | 452 base::TimeDelta timestamp, |
| 452 float radius_x, | 453 float radius_x, |
| 453 float radius_y, | 454 float radius_y, |
| 454 float angle, | 455 float angle, |
| 455 float force); | 456 float force); |
| 456 | 457 |
| 457 virtual ~TouchEvent(); | 458 virtual ~TouchEvent(); |
| 458 | 459 |
| 459 int touch_id() const { return touch_id_; } | 460 int touch_id() const { return touch_id_; } |
| 460 float radius_x() const { return radius_x_; } | 461 float radius_x() const { return radius_x_; } |
| 461 float radius_y() const { return radius_y_; } | 462 float radius_y() const { return radius_y_; } |
| 462 float rotation_angle() const { return rotation_angle_; } | 463 float rotation_angle() const { return rotation_angle_; } |
| 463 float force() const { return force_; } | 464 float force() const { return force_; } |
| 465 int source_device_id() const { return source_device_id_; } | |
| 464 | 466 |
| 465 // Relocate the touch-point to a new |origin|. | 467 // Relocate the touch-point to a new |origin|. |
| 466 // This is useful when touch event is in X Root Window coordinates, | 468 // This is useful when touch event is in X Root Window coordinates, |
| 467 // and it needs to be mapped into Aura Root Window coordinates. | 469 // and it needs to be mapped into Aura Root Window coordinates. |
| 468 void Relocate(const gfx::Point& origin); | 470 void Relocate(const gfx::Point& origin); |
| 469 | 471 |
| 470 // Used for unit tests. | 472 // Used for unit tests. |
| 471 void set_radius_x(const float r) { radius_x_ = r; } | 473 void set_radius_x(const float r) { radius_x_ = r; } |
| 472 void set_radius_y(const float r) { radius_y_ = r; } | 474 void set_radius_y(const float r) { radius_y_ = r; } |
| 475 void set_source_device_id(int source_device_id) { | |
| 476 source_device_id_ = source_device_id; | |
| 477 } | |
| 473 | 478 |
| 474 // Overridden from LocatedEvent. | 479 // Overridden from LocatedEvent. |
| 475 virtual void UpdateForRootTransform( | 480 virtual void UpdateForRootTransform( |
| 476 const gfx::Transform& inverted_root_transform) OVERRIDE; | 481 const gfx::Transform& inverted_root_transform) OVERRIDE; |
| 477 | 482 |
| 478 protected: | 483 protected: |
| 479 void set_radius(float radius_x, float radius_y) { | 484 void set_radius(float radius_x, float radius_y) { |
| 480 radius_x_ = radius_x; | 485 radius_x_ = radius_x; |
| 481 radius_y_ = radius_y; | 486 radius_y_ = radius_y; |
| 482 } | 487 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 496 float radius_x_; | 501 float radius_x_; |
| 497 | 502 |
| 498 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 503 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
| 499 float radius_y_; | 504 float radius_y_; |
| 500 | 505 |
| 501 // Angle of the major axis away from the X axis. Default 0.0. | 506 // Angle of the major axis away from the X axis. Default 0.0. |
| 502 float rotation_angle_; | 507 float rotation_angle_; |
| 503 | 508 |
| 504 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 509 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
| 505 float force_; | 510 float force_; |
| 511 | |
| 512 // The device id of the screen the event came from. | |
|
sadrul
2014/01/08 20:50:52
Mention that this defaults to -1
tdresser
2014/01/09 19:07:35
Done.
| |
| 513 int source_device_id_; | |
| 506 }; | 514 }; |
| 507 | 515 |
| 508 class EVENTS_EXPORT KeyEvent : public Event { | 516 class EVENTS_EXPORT KeyEvent : public Event { |
| 509 public: | 517 public: |
| 510 KeyEvent(const base::NativeEvent& native_event, bool is_char); | 518 KeyEvent(const base::NativeEvent& native_event, bool is_char); |
| 511 | 519 |
| 512 // Used for synthetic events. | 520 // Used for synthetic events. |
| 513 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); | 521 KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char); |
| 514 | 522 |
| 515 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') | 523 // Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA') |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 // The set of indices of ones in the binary representation of | 673 // The set of indices of ones in the binary representation of |
| 666 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 674 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
| 667 // This value is stored as a bitfield because the number of touch ids varies, | 675 // This value is stored as a bitfield because the number of touch ids varies, |
| 668 // but we currently don't need more than 32 touches at a time. | 676 // but we currently don't need more than 32 touches at a time. |
| 669 const unsigned int touch_ids_bitfield_; | 677 const unsigned int touch_ids_bitfield_; |
| 670 }; | 678 }; |
| 671 | 679 |
| 672 } // namespace ui | 680 } // namespace ui |
| 673 | 681 |
| 674 #endif // UI_EVENTS_EVENT_H_ | 682 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |