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

Side by Side Diff: ppapi/cpp/dev/touch_event_dev.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) 2011 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_DEV_TOUCH_EVENT_DEV_H_
6 #define PPAPI_CPP_DEV_TOUCH_EVENT_DEV_H_
7
8 #include "ppapi/c/dev/ppb_touch_event_dev.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_Dev {
16 public:
17 TouchPoint_Dev() : touch_point_(PP_MakeTouchPoint()) {}
18
19 TouchPoint_Dev(const PP_TouchPoint_Dev& 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_Dev touch_point_;
50 };
51
52 class TouchInputEvent_Dev : public InputEvent {
53 public:
54 /// Constructs an is_null() touch input event object.
55 TouchInputEvent_Dev();
56
57 /// Constructs a touch input event object from the given generic input event.
58 /// If the given event is itself is_null() or is not a touch input event, the
59 /// touch object will be is_null().
60 explicit TouchInputEvent_Dev(const InputEvent& event);
61
62 /// @return The number of TouchPoints in this TouchList
63 uint32_t GetTouchCount(PP_TouchListType list) const;
64
65 /// @return The TouchPoint at the given index of the given list, or an empty
66 /// TouchPoint if the index is out of range
67 TouchPoint_Dev GetTouchByIndex(PP_TouchListType list, uint32_t index) const;
68
69 /// @return The TouchPoint in the given list with the given identifier, or an
70 /// empty TouchPoint if the list does not contain a TouchPoint with that
71 /// identifier.
72 TouchPoint_Dev GetTouchById(PP_TouchListType list, uint32_t id) const;
73 };
74
75 } // namespace pp
76
77 #endif /* PPAPI_CPP_DEV_TOUCH_EVENT_DEV_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698