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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 | 401 |
402 // |location_| multiplied by an optional transformation matrix for | 402 // |location_| multiplied by an optional transformation matrix for |
403 // rotations, animations and skews. | 403 // rotations, animations and skews. |
404 gfx::PointF root_location_; | 404 gfx::PointF root_location_; |
405 }; | 405 }; |
406 | 406 |
407 // Structure for handling common fields between touch and mouse to support | 407 // Structure for handling common fields between touch and mouse to support |
408 // PointerEvents API. | 408 // PointerEvents API. |
409 struct EVENTS_EXPORT PointerDetails { | 409 struct EVENTS_EXPORT PointerDetails { |
410 public: | 410 public: |
411 PointerDetails() {} | 411 PointerDetails(); |
412 explicit PointerDetails(EventPointerType pointer_type) | 412 explicit PointerDetails(EventPointerType pointer_type); |
413 : pointer_type(pointer_type), | |
414 force(std::numeric_limits<float>::quiet_NaN()) {} | |
415 PointerDetails(EventPointerType pointer_type, | 413 PointerDetails(EventPointerType pointer_type, |
416 float radius_x, | 414 float radius_x, |
417 float radius_y, | 415 float radius_y, |
418 float force, | 416 float force, |
419 float tilt_x, | 417 float tilt_x, |
420 float tilt_y, | 418 float tilt_y, |
421 float tangential_pressure = 0.0f, | 419 float tangential_pressure = 0.0f, |
422 int twist = 0) | 420 int twist = 0, |
423 : pointer_type(pointer_type), | 421 uint32_t id = 0); |
424 // If we aren't provided with a radius on one axis, use the | 422 PointerDetails(EventPointerType pointer_type, const gfx::Vector2d& offset); |
425 // information from the other axis. | 423 PointerDetails(const PointerDetails& other); |
426 radius_x(radius_x > 0 ? radius_x : radius_y), | |
427 radius_y(radius_y > 0 ? radius_y : radius_x), | |
428 force(force), | |
429 tilt_x(tilt_x), | |
430 tilt_y(tilt_y), | |
431 tangential_pressure(tangential_pressure), | |
432 twist(twist) {} | |
433 PointerDetails(EventPointerType pointer_type, const gfx::Vector2d& offset) | |
434 : pointer_type(pointer_type), | |
435 force(std::numeric_limits<float>::quiet_NaN()), | |
436 offset(offset) {} | |
437 | 424 |
438 bool operator==(const PointerDetails& other) const { | 425 bool operator==(const PointerDetails& other) const { |
439 return pointer_type == other.pointer_type && radius_x == other.radius_x && | 426 return pointer_type == other.pointer_type && radius_x == other.radius_x && |
440 radius_y == other.radius_y && | 427 radius_y == other.radius_y && |
441 (force == other.force || | 428 (force == other.force || |
442 (std::isnan(force) && std::isnan(other.force))) && | 429 (std::isnan(force) && std::isnan(other.force))) && |
443 tilt_x == other.tilt_x && tilt_y == other.tilt_y && | 430 tilt_x == other.tilt_x && tilt_y == other.tilt_y && |
444 tangential_pressure == other.tangential_pressure && | 431 tangential_pressure == other.tangential_pressure && |
445 twist == other.twist && offset == other.offset; | 432 twist == other.twist && id == other.id && offset == other.offset; |
446 } | 433 } |
447 | 434 |
448 // The type of pointer device. | 435 // The type of pointer device. |
449 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; | 436 EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN; |
450 | 437 |
451 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. | 438 // Radius of the X (major) axis of the touch ellipse. 0.0 if unknown. |
452 float radius_x = 0.0; | 439 float radius_x = 0.0; |
453 | 440 |
454 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. | 441 // Radius of the Y (minor) axis of the touch ellipse. 0.0 if unknown. |
455 float radius_y = 0.0; | 442 float radius_y = 0.0; |
(...skipping 11 matching lines...) Expand all Loading... | |
467 // The normalized tangential pressure (or barrel pressure), typically set by | 454 // The normalized tangential pressure (or barrel pressure), typically set by |
468 // an additional control of the stylus, which has a range of [-1,1], where 0 | 455 // an additional control of the stylus, which has a range of [-1,1], where 0 |
469 // is the neutral position of the control. Always 0 if the device does not | 456 // is the neutral position of the control. Always 0 if the device does not |
470 // support it. | 457 // support it. |
471 float tangential_pressure = 0.0; | 458 float tangential_pressure = 0.0; |
472 | 459 |
473 // The clockwise rotation of a pen stylus around its own major axis, in | 460 // The clockwise rotation of a pen stylus around its own major axis, in |
474 // degrees in the range [0,359]. Always 0 if the device does not support it. | 461 // degrees in the range [0,359]. Always 0 if the device does not support it. |
475 int twist = 0; | 462 int twist = 0; |
476 | 463 |
464 // An identifier that uniquely identifies a pointer during its lifetime. | |
465 uint32_t id = 0; | |
mustaq
2017/01/31 00:24:13
Where do we set the id from lower level events? Do
| |
466 | |
sadrul
2017/01/31 17:05:13
ui::TouchEvent has a touch_id(), and a unique_even
lanwei
2017/02/01 02:58:12
This id in PointerDetails makes more senses for st
sadrul
2017/02/01 20:59:39
Replacing TouchEvent::touch_id() (and I guess Poin
| |
477 // Only used by mouse wheel events. The amount to scroll. This is in multiples | 467 // Only used by mouse wheel events. The amount to scroll. This is in multiples |
478 // of kWheelDelta. | 468 // of kWheelDelta. |
479 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up. | 469 // Note: offset_.x() > 0/offset_.y() > 0 means scroll left/up. |
480 gfx::Vector2d offset; | 470 gfx::Vector2d offset; |
481 }; | 471 }; |
482 | 472 |
483 class EVENTS_EXPORT MouseEvent : public LocatedEvent { | 473 class EVENTS_EXPORT MouseEvent : public LocatedEvent { |
484 public: | 474 public: |
485 explicit MouseEvent(const base::NativeEvent& native_event); | 475 explicit MouseEvent(const base::NativeEvent& native_event); |
486 | 476 |
(...skipping 566 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 | 1043 // dispatched. This field gets a non-zero value only for gestures that are |
1054 // released through TouchDispositionGestureFilter::SendGesture. The gesture | 1044 // released through TouchDispositionGestureFilter::SendGesture. The gesture |
1055 // events that aren't fired directly in response to processing a touch-event | 1045 // 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. | 1046 // (e.g. timer fired ones), this id is zero. See crbug.com/618738. |
1057 uint32_t unique_touch_event_id_; | 1047 uint32_t unique_touch_event_id_; |
1058 }; | 1048 }; |
1059 | 1049 |
1060 } // namespace ui | 1050 } // namespace ui |
1061 | 1051 |
1062 #endif // UI_EVENTS_EVENT_H_ | 1052 #endif // UI_EVENTS_EVENT_H_ |
OLD | NEW |