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