Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: ppapi/cpp/touch_point.h

Issue 10543159: ppapi: Add support for touch events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef PPAPI_CPP_TOUCH_POINT_H_
6 #define PPAPI_CPP_TOUCH_POINT_H_
7
8 #include "ppapi/c/ppb_input_event.h"
9 #include "ppapi/cpp/input_event.h"
10 #include "ppapi/cpp/point.h"
11
12 namespace pp {
13
14 /// Wrapper class for PP_TouchPoint.
15 class TouchPoint {
16 public:
17 TouchPoint() : touch_point_(PP_MakeTouchPoint()) {}
18
19 TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {}
20
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; }
28
29 /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space.
30 FloatPoint position() const {
31 return pp::FloatPoint(touch_point_.position);
32 }
33
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); }
37
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; }
41
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; }
47
48 private:
49 PP_TouchPoint touch_point_;
50 };
51
52 } // namespace pp
53
54 #endif /* PPAPI_CPP_TOUCH_POINT_H_ */
OLDNEW
« no previous file with comments | « ppapi/cpp/input_event.cc ('k') | ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_input_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698