| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 WebPointerProperties_h | 5 #ifndef WebPointerProperties_h |
| 6 #define WebPointerProperties_h | 6 #define WebPointerProperties_h |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 using PointerId = int32_t; |
| 14 |
| 13 // This class encapsulates the properties that are common between mouse and | 15 // This class encapsulates the properties that are common between mouse and |
| 14 // pointer events and touch points as we transition towards the unified pointer | 16 // pointer events and touch points as we transition towards the unified pointer |
| 15 // event model. | 17 // event model. |
| 16 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove | 18 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove |
| 17 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. | 19 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. |
| 18 class WebPointerProperties { | 20 class WebPointerProperties { |
| 19 public: | 21 public: |
| 20 enum class Button { | 22 enum class Button { |
| 21 kNoButton = -1, | 23 kNoButton = -1, |
| 22 kLeft, | 24 kLeft, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 | 41 |
| 40 enum class PointerType { | 42 enum class PointerType { |
| 41 kUnknown, | 43 kUnknown, |
| 42 kMouse, | 44 kMouse, |
| 43 kPen, | 45 kPen, |
| 44 kEraser, | 46 kEraser, |
| 45 kTouch, | 47 kTouch, |
| 46 kLastEntry = kTouch // Must be the last entry in the list | 48 kLastEntry = kTouch // Must be the last entry in the list |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 WebPointerProperties() | 51 explicit WebPointerProperties(PointerId id_param) |
| 50 : id(0), | 52 : id(id_param), |
| 51 force(std::numeric_limits<float>::quiet_NaN()), | 53 force(std::numeric_limits<float>::quiet_NaN()), |
| 52 tilt_x(0), | 54 tilt_x(0), |
| 53 tilt_y(0), | 55 tilt_y(0), |
| 54 tangential_pressure(0.0f), | 56 tangential_pressure(0.0f), |
| 55 twist(0), | 57 twist(0), |
| 56 button(Button::kNoButton), | 58 button(Button::kNoButton), |
| 57 pointer_type(PointerType::kUnknown), | 59 pointer_type(PointerType::kUnknown), |
| 58 movement_x(0), | 60 movement_x(0), |
| 59 movement_y(0) {} | 61 movement_y(0) {} |
| 60 | 62 |
| 61 WebPointerProperties(Button button_param, PointerType pointer_type_param) | 63 WebPointerProperties(PointerId id_param, |
| 62 : id(0), | 64 Button button_param, |
| 65 PointerType pointer_type_param) |
| 66 : id(id_param), |
| 63 force(std::numeric_limits<float>::quiet_NaN()), | 67 force(std::numeric_limits<float>::quiet_NaN()), |
| 64 tilt_x(0), | 68 tilt_x(0), |
| 65 tilt_y(0), | 69 tilt_y(0), |
| 66 tangential_pressure(0.0f), | 70 tangential_pressure(0.0f), |
| 67 twist(0), | 71 twist(0), |
| 68 button(button_param), | 72 button(button_param), |
| 69 pointer_type(pointer_type_param), | 73 pointer_type(pointer_type_param), |
| 70 movement_x(0), | 74 movement_x(0), |
| 71 movement_y(0) {} | 75 movement_y(0) {} |
| 72 | 76 |
| 73 int id; | 77 PointerId id; |
| 74 | 78 |
| 75 // The valid range is [0,1], with NaN meaning pressure is not supported by | 79 // The valid range is [0,1], with NaN meaning pressure is not supported by |
| 76 // the input device. | 80 // the input device. |
| 77 float force; | 81 float force; |
| 78 | 82 |
| 79 // Tilt of a pen stylus from surface normal as plane angles in degrees, | 83 // Tilt of a pen stylus from surface normal as plane angles in degrees, |
| 80 // Values lie in [-90,90]. A positive tiltX is to the right and a positive | 84 // Values lie in [-90,90]. A positive tiltX is to the right and a positive |
| 81 // tiltY is towards the user. | 85 // tiltY is towards the user. |
| 82 int tilt_x; | 86 int tilt_x; |
| 83 int tilt_y; | 87 int tilt_y; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 101 | 105 |
| 102 PointerType pointer_type; | 106 PointerType pointer_type; |
| 103 | 107 |
| 104 int movement_x; | 108 int movement_x; |
| 105 int movement_y; | 109 int movement_y; |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 } // namespace blink | 112 } // namespace blink |
| 109 | 113 |
| 110 #endif | 114 #endif |
| OLD | NEW |