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

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

Issue 7285010: Implement an input event resource. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
Property Changes:
Added: svn:eol-style
+ LF
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_INPUT_EVENT_H_
6 #define PPAPI_CPP_INPUT_EVENT_H_
7
8 #include "ppapi/c/ppb_input_event.h"
9 #include "ppapi/cpp/resource.h"
10
11 namespace pp {
12
13 class FloatPoint;
14 class Point;
15 class Var;
16
17 class InputEvent : public Resource {
18 public:
19 /// Default constructor that creates an is_null() InputEvent object.
20 InputEvent();
21
22 /// Constructs an input event from the given input event resource ID.
23 InputEvent(PP_Resource input_event_resource);
24
25 ~InputEvent();
26
27 /// Returns the type of input event for the given input event resource.
28 /// This is valid for all input events. Returns PP_INPUTEVENT_TYPE_UNDEFINED
29 /// if the resource is invalid.
30 PP_InputEvent_Type GetEventType() const;
31
32 /// Returns the time that the event was generated. This will be before the
33 /// current time since processing and dispatching the event has some overhead.
34 /// Use this value to compare the times the user generated two events without
35 /// being sensitive to variable processing time.
36 ///
37 /// The return value is in time ticks, which is a monotonically increasing
38 /// clock not related to the wall clock time. It will not change if the user
39 /// changes their clock or daylight savings time starts, so can be reliably
40 /// used to compare events. This means, however, that you can't correlate
41 /// event times to a particular time of day on the system clock.
42 PP_TimeTicks GetEventTimeStamp() const;
43
44 /// Returns a bitfield indicating which modifiers were down at the time of
45 /// the event. This is a combination of the flags in the
46 /// PP_InputEvent_Modifier enum.
47 ///
48 /// @return The modifiers associated with the event, or 0 if the given
49 /// resource is not a valid event resource.
50 uint32_t GetEventModifiers() const;
51
52 /// Returns the mouse position for a mouse input event.
53 ///
54 /// @return The mouse button associated with mouse down and up events. This
55 /// value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, enter, and leave
56 /// events, and for all non-mouse events.
57 PP_InputEvent_MouseButton GetMouseButton() const;
58
59 /// Returns the pixel location of a mouse input event. This value is in
60 /// floating-point units to support high-resolution input events.
61 ///
62 /// @return The point associated with the mouse event, relative to the upper-
63 /// left of the instance receiving the event. These values can be negative for
64 /// mouse drags. The return value will be (0, 0) for non-mouse events.
65 Point GetMousePosition() const;
66
67 // TODO(brettw) figure out exactly what this means.
68 int32_t GetMouseClickCount() const;
69
70 /// Indicates the amount vertically and horizontally the user has requested
71 /// to scroll by with their mouse wheel. A scroll down or to the right (where
72 /// the content moves up or left) is represented as positive values, and
73 /// a scroll up or to the left (where the content moves down or right) is
74 /// represented as negative values.
75 ///
76 /// The units are either in pixels (when scroll_by_page is false) or pages
77 /// (when scroll_by_page is true). For example, y = -3 means scroll up 3
78 /// pixels when scroll_by_page is false, and scroll up 3 pages when
79 /// scroll_by_page is true.
80 ///
81 /// This amount is system dependent and will take into account the user's
82 /// preferred scroll sensitivity and potentially also nonlinear acceleration
83 /// based on the speed of the scrolling.
84 ///
85 /// Devices will be of varying resolution. Some mice with large detents will
86 /// only generate integer scroll amounts. But fractional values are also
87 /// possible, for example, on some trackpads and newer mice that don't have
88 /// "clicks".
89 FloatPoint GetWheelDelta() const;
90
91 /// The number of "clicks" of the scroll wheel that have produced the
92 /// event. The value may have system-specific acceleration applied to it,
93 /// depending on the device. The positive and negative meanings are the same
94 /// as for GetWheelDelta().
95 ///
96 /// If you are scrolling, you probably want to use the delta values. These
97 /// tick events can be useful if you aren't doing actual scrolling and don't
98 /// want or pixel values. An example may be cycling between different items in
99 /// a game.
100 ///
101 /// You may receive fractional values for the wheel ticks if the mouse wheel
102 /// is high resolution or doesn't have "clicks". If your program wants
103 /// discrete events (as in the "picking items" example) you should accumulate
104 /// fractional click values from multiple messages until the total value
105 /// reaches positive or negative one. This should represent a similar amount
106 /// of scrolling as for a mouse that has a discrete mouse wheel.
107 FloatPoint GetWheelTicks() const;
108
109 /// Returns the DOM |keyCode| field for the keyboard event.
110 /// Chrome populates this with the Windows-style Virtual Key code of the key.
111 uint32_t GetKeyCode() const;
112
113 /// Returns the typed character for the given character event.
114 ///
115 /// @return A string var representing a single typed character for character
116 /// input events. For non-character input events the return value will be an
117 /// undefined var.
118 Var GetCharacterText() const;
119 };
120
121 } // namespace pp
122
123 #endif // PPAPI_CPP_INPUT_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698