Roll src/third_party/WebKit 0ba31e2:698efc0 (svn 192483:192500)
[chromium-blink-merge.git] / ppapi / cpp / touch_point.h
blob0868061d2e489f35d1c8b0c749667fef5c558f5c
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
3 // found in the LICENSE file.
5 #ifndef PPAPI_CPP_TOUCH_POINT_H_
6 #define PPAPI_CPP_TOUCH_POINT_H_
8 #include "ppapi/c/ppb_input_event.h"
9 #include "ppapi/cpp/input_event.h"
10 #include "ppapi/cpp/point.h"
12 namespace pp {
14 /// Wrapper class for PP_TouchPoint.
15 class TouchPoint {
16 public:
17 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {}
19 TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {}
21 /// @return The identifier for this TouchPoint. This corresponds to the order
22 /// in which the points were pressed. For example, the first point to be
23 /// pressed has an id of 0, the second has an id of 1, and so on. An id can be
24 /// reused when a touch point is released. For example, if two fingers are
25 /// down, with id 0 and 1, and finger 0 releases, the next finger to be
26 /// pressed can be assigned to id 0.
27 uint32_t id() const { return touch_point_.id; }
29 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space.
30 FloatPoint position() const {
31 return pp::FloatPoint(touch_point_.position);
34 /// @return The elliptical radii, in screen pixels, in the x and y direction
35 /// of this TouchPoint.
36 FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); }
38 /// @return The angle of rotation of the elliptical model of this TouchPoint
39 /// from the y-axis.
40 float rotation_angle() const { return touch_point_.rotation_angle; }
42 /// @return The pressure applied to this TouchPoint. This is typically a
43 /// value between 0 and 1, with 0 indicating no pressure and 1 indicating
44 /// some maximum pressure, but scaling differs depending on the hardware and
45 /// the value is not guaranteed to stay within that range.
46 float pressure() const { return touch_point_.pressure; }
48 private:
49 PP_TouchPoint touch_point_;
52 } // namespace pp
54 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */