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