Chromium Code Reviews| 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 PPAPI_CPP_TOUCH_POINT_H_ | 5 #ifndef PPAPI_CPP_TOUCH_POINT_H_ |
| 6 #define PPAPI_CPP_TOUCH_POINT_H_ | 6 #define PPAPI_CPP_TOUCH_POINT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "ppapi/c/ppb_input_event.h" | 10 #include "ppapi/c/ppb_input_event.h" |
| 11 #include "ppapi/cpp/input_event.h" | 11 #include "ppapi/cpp/input_event.h" |
| 12 #include "ppapi/cpp/point.h" | 12 #include "ppapi/cpp/point.h" |
| 13 | 13 |
| 14 namespace pp { | 14 namespace pp { |
| 15 | 15 |
| 16 /// Wrapper class for PP_TouchPoint. | 16 /// Wrapper class for PP_TouchPoint. |
| 17 class TouchPoint { | 17 class TouchPoint { |
| 18 public: | 18 public: |
| 19 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {} | 19 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {} |
| 20 | 20 |
| 21 TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {} | 21 TouchPoint(const PP_TouchPoint& point) : touch_point_(point), tilt_{0, 0} {} |
| 22 | |
| 23 TouchPoint(const PP_TouchPoint& point, const PP_FloatPoint& tilt) | |
| 24 : touch_point_(point), tilt_(tilt) {} | |
| 22 | 25 |
| 23 /// @return The identifier for this TouchPoint. This corresponds to the order | 26 /// @return The identifier for this TouchPoint. This corresponds to the order |
| 24 /// in which the points were pressed. For example, the first point to be | 27 /// in which the points were pressed. For example, the first point to be |
| 25 /// pressed has an id of 0, the second has an id of 1, and so on. An id can be | 28 /// pressed has an id of 0, the second has an id of 1, and so on. An id can be |
| 26 /// reused when a touch point is released. For example, if two fingers are | 29 /// reused when a touch point is released. For example, if two fingers are |
| 27 /// down, with id 0 and 1, and finger 0 releases, the next finger to be | 30 /// down, with id 0 and 1, and finger 0 releases, the next finger to be |
| 28 /// pressed can be assigned to id 0. | 31 /// pressed can be assigned to id 0. |
| 29 uint32_t id() const { return touch_point_.id; } | 32 uint32_t id() const { return touch_point_.id; } |
| 30 | 33 |
| 31 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space. | 34 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space. |
| 32 FloatPoint position() const { | 35 FloatPoint position() const { |
| 33 return pp::FloatPoint(touch_point_.position); | 36 return pp::FloatPoint(touch_point_.position); |
| 34 } | 37 } |
| 35 | 38 |
| 36 /// @return The elliptical radii, in screen pixels, in the x and y direction | 39 /// @return The elliptical radii, in screen pixels, in the x and y direction |
| 37 /// of this TouchPoint. | 40 /// of this TouchPoint. |
| 38 FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); } | 41 FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); } |
| 39 | 42 |
| 40 /// @return The angle of rotation of the elliptical model of this TouchPoint | 43 /// @return The angle of rotation of the elliptical model of this TouchPoint |
| 41 /// from the y-axis. | 44 /// from the y-axis. |
| 42 float rotation_angle() const { return touch_point_.rotation_angle; } | 45 float rotation_angle() const { return touch_point_.rotation_angle; } |
| 43 | 46 |
| 44 /// @return The pressure applied to this TouchPoint. This is typically a | 47 /// @return The pressure applied to this TouchPoint. This is typically a |
| 45 /// value between 0 and 1, with 0 indicating no pressure and 1 indicating | 48 /// value between 0 and 1, with 0 indicating no pressure and 1 indicating |
| 46 /// some maximum pressure, but scaling differs depending on the hardware and | 49 /// some maximum pressure, but scaling differs depending on the hardware and |
| 47 /// the value is not guaranteed to stay within that range. | 50 /// the value is not guaranteed to stay within that range. |
| 48 float pressure() const { return touch_point_.pressure; } | 51 float pressure() const { return touch_point_.pressure; } |
| 49 | 52 |
| 53 /// @return The tilt_x of this TouchPoint. This is typically a value between 0 | |
| 54 /// and 90, with 0 indiciating 0 degree and 90 indicate 90 degrees. | |
|
bbudge
2017/05/19 22:52:47
nit s/degree/degrees
and below
jkwang
2017/05/23 04:07:44
Done.
| |
| 55 float tilt_x() const { return tilt_.x; } | |
| 56 | |
| 57 /// @return The tilt_y of this TouchPoint. This is typically a value between 0 | |
| 58 /// and 90, with 0 indiciating 0 degree and 90 indicate 90 degrees. | |
| 59 float tilt_y() const { return tilt_.y; } | |
| 60 | |
| 50 private: | 61 private: |
| 51 PP_TouchPoint touch_point_; | 62 PP_TouchPoint touch_point_; |
| 63 PP_FloatPoint tilt_; | |
| 52 }; | 64 }; |
| 53 | 65 |
| 54 } // namespace pp | 66 } // namespace pp |
| 55 | 67 |
| 56 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */ | 68 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */ |
| OLD | NEW |