| 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 // This class encapsulates the properties that are common between mouse and | 13 // This class encapsulates the properties that are common between mouse and |
| 14 // pointer events and touch points as we transition towards the unified pointer | 14 // pointer events and touch points as we transition towards the unified pointer |
| 15 // event model. | 15 // event model. |
| 16 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove | 16 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove |
| 17 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. | 17 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. |
| 18 class WebPointerProperties { | 18 class WebPointerProperties { |
| 19 public: | 19 public: |
| 20 WebPointerProperties() | |
| 21 : id(0), | |
| 22 force(std::numeric_limits<float>::quiet_NaN()), | |
| 23 tiltX(0), | |
| 24 tiltY(0), | |
| 25 tangentialPressure(0.0f), | |
| 26 twist(0), | |
| 27 button(Button::NoButton), | |
| 28 pointerType(PointerType::Unknown) {} | |
| 29 | |
| 30 enum class Button { NoButton = -1, Left, Middle, Right, X1, X2, Eraser }; | 20 enum class Button { NoButton = -1, Left, Middle, Right, X1, X2, Eraser }; |
| 31 | 21 |
| 32 enum class Buttons : unsigned { | 22 enum class Buttons : unsigned { |
| 33 NoButton = 0, | 23 NoButton = 0, |
| 34 Left = 1 << 0, | 24 Left = 1 << 0, |
| 35 Right = 1 << 1, | 25 Right = 1 << 1, |
| 36 Middle = 1 << 2, | 26 Middle = 1 << 2, |
| 37 X1 = 1 << 3, | 27 X1 = 1 << 3, |
| 38 X2 = 1 << 4, | 28 X2 = 1 << 4, |
| 39 Eraser = 1 << 5 | 29 Eraser = 1 << 5 |
| 40 }; | 30 }; |
| 41 | 31 |
| 42 enum class PointerType { | 32 enum class PointerType { |
| 43 Unknown, | 33 Unknown, |
| 44 Mouse, | 34 Mouse, |
| 45 Pen, | 35 Pen, |
| 46 Eraser, | 36 Eraser, |
| 47 Touch, | 37 Touch, |
| 48 LastEntry = Touch // Must be the last entry in the list | 38 LastEntry = Touch // Must be the last entry in the list |
| 49 }; | 39 }; |
| 50 | 40 |
| 41 WebPointerProperties() |
| 42 : id(0), |
| 43 force(std::numeric_limits<float>::quiet_NaN()), |
| 44 tiltX(0), |
| 45 tiltY(0), |
| 46 tangentialPressure(0.0f), |
| 47 twist(0), |
| 48 button(Button::NoButton), |
| 49 pointerType(PointerType::Unknown) {} |
| 50 |
| 51 WebPointerProperties(Button buttonParam, PointerType pointerTypeParam) |
| 52 : id(0), |
| 53 force(std::numeric_limits<float>::quiet_NaN()), |
| 54 tiltX(0), |
| 55 tiltY(0), |
| 56 tangentialPressure(0.0f), |
| 57 twist(0), |
| 58 button(buttonParam), |
| 59 pointerType(pointerTypeParam) {} |
| 60 |
| 51 int id; | 61 int id; |
| 52 | 62 |
| 53 // The valid range is [0,1], with NaN meaning pressure is not supported by | 63 // The valid range is [0,1], with NaN meaning pressure is not supported by |
| 54 // the input device. | 64 // the input device. |
| 55 float force; | 65 float force; |
| 56 | 66 |
| 57 // Tilt of a pen stylus from surface normal as plane angles in degrees, | 67 // Tilt of a pen stylus from surface normal as plane angles in degrees, |
| 58 // Values lie in [-90,90]. A positive tiltX is to the right and a positive | 68 // Values lie in [-90,90]. A positive tiltX is to the right and a positive |
| 59 // tiltY is towards the user. | 69 // tiltY is towards the user. |
| 60 int tiltX; | 70 int tiltX; |
| 61 int tiltY; | 71 int tiltY; |
| 62 | 72 |
| 63 // The normalized tangential pressure (or barrel pressure), typically set by | 73 // The normalized tangential pressure (or barrel pressure), typically set by |
| 64 // an additional control of the stylus, which has a range of [-1,1], where 0 | 74 // an additional control of the stylus, which has a range of [-1,1], where 0 |
| 65 // is the neutral position of the control. Always 0 if the device does not | 75 // is the neutral position of the control. Always 0 if the device does not |
| 66 // support it. | 76 // support it. |
| 67 float tangentialPressure; | 77 float tangentialPressure; |
| 68 | 78 |
| 69 // The clockwise rotation of a pen stylus around its own major axis, in | 79 // The clockwise rotation of a pen stylus around its own major axis, in |
| 70 // degrees in the range [0,359]. Always 0 if the device does not support it. | 80 // degrees in the range [0,359]. Always 0 if the device does not support it. |
| 71 int twist; | 81 int twist; |
| 72 | 82 |
| 73 Button button; | 83 Button button; |
| 74 PointerType pointerType; | 84 PointerType pointerType; |
| 75 }; | 85 }; |
| 76 | 86 |
| 77 } // namespace blink | 87 } // namespace blink |
| 78 | 88 |
| 79 #endif | 89 #endif |
| OLD | NEW |