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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 29 matching lines...) Expand all Loading... |
40 class MouseEvent; | 40 class MouseEvent; |
41 class MouseWheelEvent; | 41 class MouseWheelEvent; |
42 class PointerEvent; | 42 class PointerEvent; |
43 class ScrollEvent; | 43 class ScrollEvent; |
44 class TouchEvent; | 44 class TouchEvent; |
45 enum class DomCode; | 45 enum class DomCode; |
46 class Event; | 46 class Event; |
47 class MouseWheelEvent; | 47 class MouseWheelEvent; |
48 | 48 |
49 using ScopedEvent = std::unique_ptr<Event>; | 49 using ScopedEvent = std::unique_ptr<Event>; |
| 50 using PointerId = int32_t; |
50 | 51 |
51 class EVENTS_EXPORT Event { | 52 class EVENTS_EXPORT Event { |
52 public: | 53 public: |
53 static std::unique_ptr<Event> Clone(const Event& event); | 54 static std::unique_ptr<Event> Clone(const Event& event); |
54 | 55 |
55 virtual ~Event(); | 56 virtual ~Event(); |
56 | 57 |
57 class DispatcherApi { | 58 class DispatcherApi { |
58 public: | 59 public: |
59 explicit DispatcherApi(Event* event) : event_(event) {} | 60 explicit DispatcherApi(Event* event) : event_(event) {} |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // rotations, animations and skews. | 406 // rotations, animations and skews. |
406 gfx::PointF root_location_; | 407 gfx::PointF root_location_; |
407 }; | 408 }; |
408 | 409 |
409 // Structure for handling common fields between touch and mouse to support | 410 // Structure for handling common fields between touch and mouse to support |
410 // PointerEvents API. | 411 // PointerEvents API. |
411 struct EVENTS_EXPORT PointerDetails { | 412 struct EVENTS_EXPORT PointerDetails { |
412 public: | 413 public: |
413 PointerDetails(); | 414 PointerDetails(); |
414 explicit PointerDetails(EventPointerType pointer_type, | 415 explicit PointerDetails(EventPointerType pointer_type, |
415 int pointer_id = kUnknownPointerId); | 416 PointerId pointer_id = kUnknownPointerId); |
416 PointerDetails(EventPointerType pointer_type, | 417 PointerDetails(EventPointerType pointer_type, |
417 int pointer_id, | 418 PointerId pointer_id, |
418 float radius_x, | 419 float radius_x, |
419 float radius_y, | 420 float radius_y, |
420 float force, | 421 float force, |
421 float tilt_x = 0.0f, | 422 float tilt_x = 0.0f, |
422 float tilt_y = 0.0f, | 423 float tilt_y = 0.0f, |
423 float tangential_pressure = 0.0f, | 424 float tangential_pressure = 0.0f, |
424 int twist = 0); | 425 int twist = 0); |
425 PointerDetails(EventPointerType pointer_type, | 426 PointerDetails(EventPointerType pointer_type, |
426 const gfx::Vector2d& pointer_offset, | 427 const gfx::Vector2d& pointer_offset, |
427 int pointer_id = kUnknownPointerId); | 428 PointerId pointer_id = kUnknownPointerId); |
428 PointerDetails(const PointerDetails& other); | 429 PointerDetails(const PointerDetails& other); |
429 | 430 |
430 bool operator==(const PointerDetails& other) const { | 431 bool operator==(const PointerDetails& other) const { |
431 return pointer_type == other.pointer_type && radius_x == other.radius_x && | 432 return pointer_type == other.pointer_type && radius_x == other.radius_x && |
432 radius_y == other.radius_y && | 433 radius_y == other.radius_y && |
433 (force == other.force || | 434 (force == other.force || |
434 (std::isnan(force) && std::isnan(other.force))) && | 435 (std::isnan(force) && std::isnan(other.force))) && |
435 tilt_x == other.tilt_x && tilt_y == other.tilt_y && | 436 tilt_x == other.tilt_x && tilt_y == other.tilt_y && |
436 tangential_pressure == other.tangential_pressure && | 437 tangential_pressure == other.tangential_pressure && |
437 twist == other.twist && id == other.id && offset == other.offset; | 438 twist == other.twist && id == other.id && offset == other.offset; |
438 } | 439 } |
439 | 440 |
440 // A value for pointer id which means it needs to be initialized for all | 441 // A value for pointer id which means it needs to be initialized for all |
441 // pointer types. | 442 // pointer types. |
442 static const int kUnknownPointerId; | 443 static const PointerId kUnknownPointerId; |
443 | 444 |
444 // The type of pointer device. | 445 // The type of pointer device. |
445 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; | 446 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; |
446 | 447 |
447 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. | 448 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. |
448 float radius_x = 0.0; | 449 float radius_x = 0.0; |
449 | 450 |
450 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 451 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
451 float radius_y = 0.0; | 452 float radius_y = 0.0; |
452 | 453 |
(...skipping 11 matching lines...) Expand all Loading... |
464 // an additional control of the stylus, which has a range of [-1,1], where 0 | 465 // an additional control of the stylus, which has a range of [-1,1], where 0 |
465 // is the neutral position of the control. Always 0 if the device does not | 466 // is the neutral position of the control. Always 0 if the device does not |
466 // support it. | 467 // support it. |
467 float tangential_pressure = 0.0; | 468 float tangential_pressure = 0.0; |
468 | 469 |
469 // The clockwise rotation of a pen stylus around its own major axis, in | 470 // The clockwise rotation of a pen stylus around its own major axis, in |
470 // degrees in the range [0,359]. Always 0 if the device does not support it. | 471 // degrees in the range [0,359]. Always 0 if the device does not support it. |
471 int twist = 0; | 472 int twist = 0; |
472 | 473 |
473 // An identifier that uniquely identifies a pointer during its lifetime. | 474 // An identifier that uniquely identifies a pointer during its lifetime. |
474 int id = 0; | 475 PointerId id = 0; |
475 | 476 |
476 // Only used by mouse wheel events. The amount to scroll. This is in multiples | 477 // Only used by mouse wheel events. The amount to scroll. This is in multiples |
477 // of kWheelDelta. | 478 // of kWheelDelta. |
478 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up. | 479 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up. |
479 gfx::Vector2d offset; | 480 gfx::Vector2d offset; |
480 }; | 481 }; |
481 | 482 |
482 class EVENTS_EXPORT MouseEvent : public LocatedEvent { | 483 class EVENTS_EXPORT MouseEvent : public LocatedEvent { |
483 public: | 484 public: |
484 static const int32_t kMousePointerId; | 485 static const PointerId kMousePointerId; |
485 | 486 |
486 explicit MouseEvent(const base::NativeEvent& native_event); | 487 explicit MouseEvent(const base::NativeEvent& native_event); |
487 | 488 |
488 // |pointer_event.IsMousePointerEvent()| must be true. | 489 // |pointer_event.IsMousePointerEvent()| must be true. |
489 // Note: If |pointer_event| is a mouse wheel pointer event, use the | 490 // Note: If |pointer_event| is a mouse wheel pointer event, use the |
490 // MouseWheelEvent version of this function to convert to a MouseWheelEvent | 491 // MouseWheelEvent version of this function to convert to a MouseWheelEvent |
491 // instead. | 492 // instead. |
492 explicit MouseEvent(const PointerEvent& pointer_event); | 493 explicit MouseEvent(const PointerEvent& pointer_event); |
493 | 494 |
494 // Create a new MouseEvent based on the provided model. | 495 // Create a new MouseEvent based on the provided model. |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 // dispatched. This field gets a non-zero value only for gestures that are | 1054 // dispatched. This field gets a non-zero value only for gestures that are |
1054 // released through TouchDispositionGestureFilter::SendGesture. The gesture | 1055 // released through TouchDispositionGestureFilter::SendGesture. The gesture |
1055 // events that aren't fired directly in response to processing a touch-event | 1056 // events that aren't fired directly in response to processing a touch-event |
1056 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. | 1057 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. |
1057 uint32_t unique_touch_event_id_; | 1058 uint32_t unique_touch_event_id_; |
1058 }; | 1059 }; |
1059 | 1060 |
1060 } // namespace ui | 1061 } // namespace ui |
1061 | 1062 |
1062 #endif // UI_EVENTS_EVENT_H_ | 1063 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |