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> | |
9 #include <limits> | 8 #include <limits> |
10 | 9 |
11 namespace blink { | 10 namespace blink { |
12 | 11 |
13 // This class encapsulates the properties that are common between mouse and | 12 // This class encapsulates the properties that are common between mouse and |
14 // pointer events and touch points as we transition towards the unified pointer | 13 // pointer events and touch points as we transition towards the unified pointer |
15 // event model. | 14 // event model. |
16 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove | 15 // TODO(e_hakkinen): Replace WebTouchEvent with WebPointerEvent, remove |
17 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. | 16 // WebTouchEvent and WebTouchPoint and merge this into WebPointerEvent. |
18 class WebPointerProperties { | 17 class WebPointerProperties { |
19 public: | 18 public: |
20 WebPointerProperties() | 19 WebPointerProperties() |
21 : button(Button::NoButton) | 20 : button(ButtonNone) |
22 , id(0) | 21 , id(0) |
23 , force(std::numeric_limits<float>::quiet_NaN()) | 22 , force(std::numeric_limits<float>::quiet_NaN()) |
24 , tiltX(0) | 23 , tiltX(0) |
25 , tiltY(0) | 24 , tiltY(0) |
26 , pointerType(PointerType::Unknown) | 25 , pointerType(PointerType::Unknown) |
27 { | 26 { |
28 } | 27 } |
29 | 28 |
30 enum class Button : std::int8_t { | 29 enum Button { |
31 NoButton = -1, | 30 ButtonNone = -1, |
32 Left, | 31 ButtonLeft, |
33 Middle, | 32 ButtonMiddle, |
34 Right | 33 ButtonRight |
35 }; | 34 }; |
36 | 35 |
37 enum class PointerType : std::int8_t { | 36 enum class PointerType : int { |
38 Unknown, | 37 Unknown, |
39 Mouse, | 38 Mouse, |
40 Pen, | 39 Pen, |
41 Touch, | 40 Touch, |
42 LastEntry = Touch // Must be the last entry in the list | 41 LastEntry = Touch // Must be the last entry in the list |
43 }; | 42 }; |
44 | 43 |
45 Button button; | 44 Button button; |
46 | 45 |
47 int id; | 46 int id; |
48 | 47 |
49 // The valid range is [0,1], with NaN meaning pressure is not supported by | 48 // The valid range is [0,1], with NaN meaning pressure is not supported by |
50 // the input device. | 49 // the input device. |
51 float force; | 50 float force; |
52 | 51 |
53 // Tilt of a pen stylus from surface normal as plane angles in degrees, | 52 // Tilt of a pen stylus from surface normal as plane angles in degrees, |
54 // Values lie in [-90,90]. A positive tiltX is to the right and a positive | 53 // Values lie in [-90,90]. A positive tiltX is to the right and a positive |
55 // tiltY is towards the user. | 54 // tiltY is towards the user. |
56 int tiltX; | 55 int tiltX; |
57 int tiltY; | 56 int tiltY; |
58 | 57 |
59 PointerType pointerType; | 58 PointerType pointerType; |
60 }; | 59 }; |
61 | 60 |
62 } // namespace blink | 61 } // namespace blink |
63 | 62 |
64 #endif | 63 #endif |
OLD | NEW |