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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/touch_point.h
diff --git a/ppapi/cpp/touch_point.h b/ppapi/cpp/touch_point.h
new file mode 100644
index 0000000000000000000000000000000000000000..0868061d2e489f35d1c8b0c749667fef5c558f5c
--- /dev/null
+++ b/ppapi/cpp/touch_point.h
@@ -0,0 +1,54 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_TOUCH_POINT_H_
+#define PPAPI_CPP_TOUCH_POINT_H_
+
+#include "ppapi/c/ppb_input_event.h"
+#include "ppapi/cpp/input_event.h"
+#include "ppapi/cpp/point.h"
+
+namespace pp {
+
+/// Wrapper class for PP_TouchPoint.
+class TouchPoint {
+ public:
+ TouchPoint() : touch_point_(PP_MakeTouchPoint()) {}
+
+ TouchPoint(const PP_TouchPoint& point) : touch_point_(point) {}
+
+ /// @return The identifier for this TouchPoint. This corresponds to the order
+ /// in which the points were pressed. For example, the first point to be
+ /// pressed has an id of 0, the second has an id of 1, and so on. An id can be
+ /// reused when a touch point is released. For example, if two fingers are
+ /// down, with id 0 and 1, and finger 0 releases, the next finger to be
+ /// pressed can be assigned to id 0.
+ uint32_t id() const { return touch_point_.id; }
+
+ /// @return The x-y coordinates of this TouchPoint, in DOM coordinate space.
+ FloatPoint position() const {
+ return pp::FloatPoint(touch_point_.position);
+ }
+
+ /// @return The elliptical radii, in screen pixels, in the x and y direction
+ /// of this TouchPoint.
+ FloatPoint radii() const { return pp::FloatPoint(touch_point_.radius); }
+
+ /// @return The angle of rotation of the elliptical model of this TouchPoint
+ /// from the y-axis.
+ float rotation_angle() const { return touch_point_.rotation_angle; }
+
+ /// @return The pressure applied to this TouchPoint. This is typically a
+ /// value between 0 and 1, with 0 indicating no pressure and 1 indicating
+ /// some maximum pressure, but scaling differs depending on the hardware and
+ /// the value is not guaranteed to stay within that range.
+ float pressure() const { return touch_point_.pressure; }
+
+ private:
+ PP_TouchPoint touch_point_;
+};
+
+} // namespace pp
+
+#endif /* PPAPI_CPP_TOUCH_POINT_H_ */
« 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