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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Immediately stops the propagation of the event. This must be called only | 207 // 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 | 208 // 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. | 209 // be in the list will not receive the event after this is called. |
210 // Note that StopPropagation() can be called only for cancelable events. | 210 // Note that StopPropagation() can be called only for cancelable events. |
211 void StopPropagation(); | 211 void StopPropagation(); |
212 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 212 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
213 | 213 |
214 // Marks the event as having been handled. A handled event does not reach the | 214 |
215 // next event phase. For example, if an event is handled during the pre-target | 215 // 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 | 216 // phase, then the event is dispatched to all pre-target handlers, but not to |
217 // the target or post-target handlers. | 217 // the target or post-target handlers. |
218 // Note that SetHandled() can be called only for cancelable events. | 218 // Note that SetHandled() can be called only for cancelable events. |
219 void SetHandled(); | 219 void SetHandled(); |
220 bool handled() const { return result_ != ER_UNHANDLED; } | 220 bool handled() const { return result_ != ER_UNHANDLED; } |
221 | 221 |
222 protected: | 222 protected: |
223 Event(EventType type, base::TimeDelta time_stamp, int flags); | 223 Event(EventType type, base::TimeDelta time_stamp, int flags); |
224 Event(const base::NativeEvent& native_event, EventType type, int flags); | 224 Event(const base::NativeEvent& native_event, EventType type, int flags); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // If source / target windows are provided, the model location will be | 486 // If source / target windows are provided, the model location will be |
487 // converted from |source| coordinate system to |target| coordinate system. | 487 // converted from |source| coordinate system to |target| coordinate system. |
488 template <class T> | 488 template <class T> |
489 TouchEvent(const TouchEvent& model, T* source, T* target) | 489 TouchEvent(const TouchEvent& model, T* source, T* target) |
490 : LocatedEvent(model, source, target), | 490 : LocatedEvent(model, source, target), |
491 touch_id_(model.touch_id_), | 491 touch_id_(model.touch_id_), |
492 unique_event_id_(model.unique_event_id_), | 492 unique_event_id_(model.unique_event_id_), |
493 radius_x_(model.radius_x_), | 493 radius_x_(model.radius_x_), |
494 radius_y_(model.radius_y_), | 494 radius_y_(model.radius_y_), |
495 rotation_angle_(model.rotation_angle_), | 495 rotation_angle_(model.rotation_angle_), |
496 force_(model.force_) {} | 496 force_(model.force_), |
| 497 may_cause_scrolling_(model.may_cause_scrolling_) {} |
497 | 498 |
498 TouchEvent(EventType type, | 499 TouchEvent(EventType type, |
499 const gfx::PointF& location, | 500 const gfx::PointF& location, |
500 int touch_id, | 501 int touch_id, |
501 base::TimeDelta time_stamp); | 502 base::TimeDelta time_stamp); |
502 | 503 |
503 TouchEvent(EventType type, | 504 TouchEvent(EventType type, |
504 const gfx::PointF& location, | 505 const gfx::PointF& location, |
505 int flags, | 506 int flags, |
506 int touch_id, | 507 int touch_id, |
507 base::TimeDelta timestamp, | 508 base::TimeDelta timestamp, |
508 float radius_x, | 509 float radius_x, |
509 float radius_y, | 510 float radius_y, |
510 float angle, | 511 float angle, |
511 float force); | 512 float force); |
512 | 513 |
513 ~TouchEvent() override; | 514 ~TouchEvent() override; |
514 | 515 |
515 // The id of the pointer this event modifies. | 516 // The id of the pointer this event modifies. |
516 int touch_id() const { return touch_id_; } | 517 int touch_id() const { return touch_id_; } |
517 // A unique identifier for this event. | 518 // A unique identifier for this event. |
518 uint64 unique_event_id() const { return unique_event_id_; } | 519 uint64 unique_event_id() const { return unique_event_id_; } |
519 float radius_x() const { return radius_x_; } | 520 float radius_x() const { return radius_x_; } |
520 float radius_y() const { return radius_y_; } | 521 float radius_y() const { return radius_y_; } |
521 float rotation_angle() const { return rotation_angle_; } | 522 float rotation_angle() const { return rotation_angle_; } |
522 float force() const { return force_; } | 523 float force() const { return force_; } |
523 | 524 |
| 525 void set_may_cause_scrolling(bool causes) { may_cause_scrolling_ = causes; } |
| 526 bool may_cause_scrolling() const { return may_cause_scrolling_; } |
| 527 |
524 // Used for unit tests. | 528 // Used for unit tests. |
525 void set_radius_x(const float r) { radius_x_ = r; } | 529 void set_radius_x(const float r) { radius_x_ = r; } |
526 void set_radius_y(const float r) { radius_y_ = r; } | 530 void set_radius_y(const float r) { radius_y_ = r; } |
527 | 531 |
528 // Overridden from LocatedEvent. | 532 // Overridden from LocatedEvent. |
529 void UpdateForRootTransform( | 533 void UpdateForRootTransform( |
530 const gfx::Transform& inverted_root_transform) override; | 534 const gfx::Transform& inverted_root_transform) override; |
531 | 535 |
532 // Marks the event as not participating in synchronous gesture recognition. | 536 // Marks the event as not participating in synchronous gesture recognition. |
533 void DisableSynchronousHandling(); | 537 void DisableSynchronousHandling(); |
(...skipping 25 matching lines...) Expand all Loading... |
559 float radius_x_; | 563 float radius_x_; |
560 | 564 |
561 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 565 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
562 float radius_y_; | 566 float radius_y_; |
563 | 567 |
564 // Angle of the major axis away from the X axis. Default 0.0. | 568 // Angle of the major axis away from the X axis. Default 0.0. |
565 float rotation_angle_; | 569 float rotation_angle_; |
566 | 570 |
567 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. | 571 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. |
568 float force_; | 572 float force_; |
| 573 |
| 574 // Whether the (unhandled) touch event will produce a scroll event (e.g., a |
| 575 // touchmove that exceeds the platform slop region, or a touchend that |
| 576 // causes a fling). Defaults to false. |
| 577 bool may_cause_scrolling_; |
569 }; | 578 }; |
570 | 579 |
571 // An interface that individual platforms can use to store additional data on | 580 // An interface that individual platforms can use to store additional data on |
572 // KeyEvent. | 581 // KeyEvent. |
573 // | 582 // |
574 // Currently only used in mojo. | 583 // Currently only used in mojo. |
575 class EVENTS_EXPORT ExtendedKeyEventData { | 584 class EVENTS_EXPORT ExtendedKeyEventData { |
576 public: | 585 public: |
577 virtual ~ExtendedKeyEventData() {} | 586 virtual ~ExtendedKeyEventData() {} |
578 | 587 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 831 |
823 const GestureEventDetails& details() const { return details_; } | 832 const GestureEventDetails& details() const { return details_; } |
824 | 833 |
825 private: | 834 private: |
826 GestureEventDetails details_; | 835 GestureEventDetails details_; |
827 }; | 836 }; |
828 | 837 |
829 } // namespace ui | 838 } // namespace ui |
830 | 839 |
831 #endif // UI_EVENTS_EVENT_H_ | 840 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |