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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() | 198 // Convenience methods to cast |this| to a GestureEvent. IsGestureEvent() |
199 // must be true as a precondition to calling these methods. | 199 // must be true as a precondition to calling these methods. |
200 GestureEvent* AsGestureEvent(); | 200 GestureEvent* AsGestureEvent(); |
201 const GestureEvent* AsGestureEvent() const; | 201 const GestureEvent* AsGestureEvent() const; |
202 | 202 |
203 // Returns true if the event has a valid |native_event_|. | 203 // Returns true if the event has a valid |native_event_|. |
204 bool HasNativeEvent() const; | 204 bool HasNativeEvent() const; |
205 | 205 |
| 206 // Marks the event as not participating in synchronous gesture recognition. |
| 207 void DisableSynchronousHandling(); |
| 208 bool synchronous_handling_disabled() const { |
| 209 return !!(result_ & ER_DISABLE_SYNC_HANDLING); |
| 210 } |
| 211 |
206 // Immediately stops the propagation of the event. This must be called only | 212 // Immediately stops the propagation of the event. This must be called only |
207 // from an EventHandler during an event-dispatch. Any event handler that may | 213 // from an EventHandler during an event-dispatch. Any event handler that may |
208 // be in the list will not receive the event after this is called. | 214 // be in the list will not receive the event after this is called. |
209 // Note that StopPropagation() can be called only for cancelable events. | 215 // Note that StopPropagation() can be called only for cancelable events. |
210 void StopPropagation(); | 216 void StopPropagation(); |
211 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 217 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
212 | 218 |
213 // Marks the event as having been handled. A handled event does not reach the | 219 // Marks the event as having been handled. A handled event does not reach the |
214 // next event phase. For example, if an event is handled during the pre-target | 220 // next event phase. For example, if an event is handled during the pre-target |
215 // phase, then the event is dispatched to all pre-target handlers, but not to | 221 // phase, then the event is dispatched to all pre-target handlers, but not to |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 public: | 487 public: |
482 explicit TouchEvent(const base::NativeEvent& native_event); | 488 explicit TouchEvent(const base::NativeEvent& native_event); |
483 | 489 |
484 // Create a new TouchEvent which is identical to the provided model. | 490 // Create a new TouchEvent which is identical to the provided model. |
485 // If source / target windows are provided, the model location will be | 491 // If source / target windows are provided, the model location will be |
486 // converted from |source| coordinate system to |target| coordinate system. | 492 // converted from |source| coordinate system to |target| coordinate system. |
487 template <class T> | 493 template <class T> |
488 TouchEvent(const TouchEvent& model, T* source, T* target) | 494 TouchEvent(const TouchEvent& model, T* source, T* target) |
489 : LocatedEvent(model, source, target), | 495 : LocatedEvent(model, source, target), |
490 touch_id_(model.touch_id_), | 496 touch_id_(model.touch_id_), |
| 497 touch_event_id_(model.touch_event_id_), |
491 radius_x_(model.radius_x_), | 498 radius_x_(model.radius_x_), |
492 radius_y_(model.radius_y_), | 499 radius_y_(model.radius_y_), |
493 rotation_angle_(model.rotation_angle_), | 500 rotation_angle_(model.rotation_angle_), |
494 force_(model.force_) { | 501 force_(model.force_) {} |
495 } | |
496 | 502 |
497 TouchEvent(EventType type, | 503 TouchEvent(EventType type, |
498 const gfx::PointF& location, | 504 const gfx::PointF& location, |
499 int touch_id, | 505 int touch_id, |
500 base::TimeDelta time_stamp); | 506 base::TimeDelta time_stamp); |
501 | 507 |
502 TouchEvent(EventType type, | 508 TouchEvent(EventType type, |
503 const gfx::PointF& location, | 509 const gfx::PointF& location, |
504 int flags, | 510 int flags, |
505 int touch_id, | 511 int touch_id, |
506 base::TimeDelta timestamp, | 512 base::TimeDelta timestamp, |
507 float radius_x, | 513 float radius_x, |
508 float radius_y, | 514 float radius_y, |
509 float angle, | 515 float angle, |
510 float force); | 516 float force); |
511 | 517 |
512 ~TouchEvent() override; | 518 ~TouchEvent() override; |
513 | 519 |
514 int touch_id() const { return touch_id_; } | 520 int touch_id() const { return touch_id_; } |
| 521 int touch_event_id() const { return touch_event_id_; } |
515 float radius_x() const { return radius_x_; } | 522 float radius_x() const { return radius_x_; } |
516 float radius_y() const { return radius_y_; } | 523 float radius_y() const { return radius_y_; } |
517 float rotation_angle() const { return rotation_angle_; } | 524 float rotation_angle() const { return rotation_angle_; } |
518 float force() const { return force_; } | 525 float force() const { return force_; } |
519 | 526 |
520 // Used for unit tests. | 527 // Used for unit tests. |
521 void set_radius_x(const float r) { radius_x_ = r; } | 528 void set_radius_x(const float r) { radius_x_ = r; } |
522 void set_radius_y(const float r) { radius_y_ = r; } | 529 void set_radius_y(const float r) { radius_y_ = r; } |
523 | 530 |
524 // Overridden from LocatedEvent. | 531 // Overridden from LocatedEvent. |
525 void UpdateForRootTransform( | 532 void UpdateForRootTransform( |
526 const gfx::Transform& inverted_root_transform) override; | 533 const gfx::Transform& inverted_root_transform) override; |
527 | 534 |
528 protected: | 535 protected: |
529 void set_radius(float radius_x, float radius_y) { | 536 void set_radius(float radius_x, float radius_y) { |
530 radius_x_ = radius_x; | 537 radius_x_ = radius_x; |
531 radius_y_ = radius_y; | 538 radius_y_ = radius_y; |
532 } | 539 } |
533 | 540 |
534 void set_rotation_angle(float rotation_angle) { | 541 void set_rotation_angle(float rotation_angle) { |
535 rotation_angle_ = rotation_angle; | 542 rotation_angle_ = rotation_angle; |
536 } | 543 } |
537 | 544 |
538 void set_force(float force) { force_ = force; } | 545 void set_force(float force) { force_ = force; } |
539 | 546 |
540 private: | 547 private: |
| 548 int get_next_touch_event_id(); |
| 549 |
541 // The identity (typically finger) of the touch starting at 0 and incrementing | 550 // The identity (typically finger) of the touch starting at 0 and incrementing |
542 // for each separable additional touch that the hardware can detect. | 551 // for each separable additional touch that the hardware can detect. |
543 const int touch_id_; | 552 const int touch_id_; |
544 | 553 |
| 554 // A unique identifier for the touch event. Currently only used for |
| 555 // checking equality of touch events for debugging purposes. |
| 556 const int touch_event_id_; |
| 557 |
545 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. | 558 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. |
546 float radius_x_; | 559 float radius_x_; |
547 | 560 |
548 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 561 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
549 float radius_y_; | 562 float radius_y_; |
550 | 563 |
551 // Angle of the major axis away from the X axis. Default 0.0. | 564 // Angle of the major axis away from the X axis. Default 0.0. |
552 float rotation_angle_; | 565 float rotation_angle_; |
553 | 566 |
554 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 567 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 820 |
808 const GestureEventDetails& details() const { return details_; } | 821 const GestureEventDetails& details() const { return details_; } |
809 | 822 |
810 private: | 823 private: |
811 GestureEventDetails details_; | 824 GestureEventDetails details_; |
812 }; | 825 }; |
813 | 826 |
814 } // namespace ui | 827 } // namespace ui |
815 | 828 |
816 #endif // UI_EVENTS_EVENT_H_ | 829 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |