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

Side by Side Diff: ui/base/events.h

Issue 10917075: events: Move some files into ui/base/events/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
« no previous file with comments | « ui/base/event_unittest.cc ('k') | ui/base/events/event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 UI_BASE_EVENTS_H_
6 #define UI_BASE_EVENTS_H_
7
8 #include "base/event_types.h"
9 #include "ui/base/keycodes/keyboard_codes.h"
10 #include "ui/gfx/native_widget_types.h"
11
12 #if defined(OS_WIN)
13 #include <windows.h>
14 #endif
15
16 namespace gfx {
17 class Point;
18 }
19
20 namespace base {
21 class TimeDelta;
22 }
23
24 namespace ui {
25
26 // Event types. (prefixed because of a conflict with windows headers)
27 enum EventType {
28 ET_UNKNOWN = 0,
29 ET_MOUSE_PRESSED,
30 ET_MOUSE_DRAGGED,
31 ET_MOUSE_RELEASED,
32 ET_MOUSE_MOVED,
33 ET_MOUSE_ENTERED,
34 ET_MOUSE_EXITED,
35 ET_KEY_PRESSED,
36 ET_KEY_RELEASED,
37 ET_MOUSEWHEEL,
38 ET_MOUSE_CAPTURE_CHANGED, // Event has no location.
39 ET_TOUCH_RELEASED,
40 ET_TOUCH_PRESSED,
41 ET_TOUCH_MOVED,
42 ET_TOUCH_STATIONARY,
43 ET_TOUCH_CANCELLED,
44 ET_DROP_TARGET_EVENT,
45 ET_FOCUS_CHANGE,
46 ET_TRANSLATED_KEY_PRESS,
47 ET_TRANSLATED_KEY_RELEASE,
48
49 // GestureEvent types
50 ET_GESTURE_SCROLL_BEGIN,
51 ET_GESTURE_SCROLL_END,
52 ET_GESTURE_SCROLL_UPDATE,
53 ET_GESTURE_TAP,
54 ET_GESTURE_TAP_DOWN,
55 ET_GESTURE_BEGIN, // Sent before any other gesture types.
56 ET_GESTURE_END, // Sent after any other gestures.
57 ET_GESTURE_DOUBLE_TAP,
58 ET_GESTURE_TWO_FINGER_TAP,
59 ET_GESTURE_PINCH_BEGIN,
60 ET_GESTURE_PINCH_END,
61 ET_GESTURE_PINCH_UPDATE,
62 ET_GESTURE_LONG_PRESS,
63 // A SWIPE gesture can happen at the end of a TAP_UP gesture if the
64 // finger(s) were moving quickly before they are released.
65 ET_GESTURE_MULTIFINGER_SWIPE,
66
67 // Scroll support.
68 // TODO[davemoore] we need to unify these events w/ touch and gestures.
69 ET_SCROLL,
70 ET_SCROLL_FLING_START,
71 ET_SCROLL_FLING_CANCEL,
72 };
73
74 // Event flags currently supported
75 enum EventFlags {
76 EF_NONE = 0, // Used to denote no flags explicitly
77 EF_CAPS_LOCK_DOWN = 1 << 0,
78 EF_SHIFT_DOWN = 1 << 1,
79 EF_CONTROL_DOWN = 1 << 2,
80 EF_ALT_DOWN = 1 << 3,
81 EF_LEFT_MOUSE_BUTTON = 1 << 4,
82 EF_MIDDLE_MOUSE_BUTTON = 1 << 5,
83 EF_RIGHT_MOUSE_BUTTON = 1 << 6,
84 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX
85 EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc)
86 };
87
88 // Flags specific to mouse events
89 enum MouseEventFlags {
90 EF_IS_DOUBLE_CLICK = 1 << 16,
91 EF_IS_TRIPLE_CLICK = 1 << 17,
92 EF_IS_NON_CLIENT = 1 << 18,
93 EF_IS_SYNTHESIZED = 1 << 19, // Only for Aura. See ui/aura/root_window.h
94 EF_FROM_TOUCH = 1 << 20, // Indicates this mouse event is generated
95 // from an unconsumed touch/gesture event.
96 };
97
98 // Result of dispatching an event.
99 enum EventResult {
100 ER_UNHANDLED = 0, // The event hasn't been handled. The event can be
101 // propagated to other handlers.
102 ER_HANDLED, // The event has already been handled, but it can still be
103 // propagated to other handlers.
104 ER_CONSUMED, // The event has been handled, and it should not be
105 // propagated to other handlers.
106 };
107
108 enum TouchStatus {
109 TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate
110 // that the touch event was not handled.
111 TOUCH_STATUS_START, // The touch event initiated a touch sequence.
112 TOUCH_STATUS_CONTINUE, // The touch event is part of a previously
113 // started touch sequence.
114 TOUCH_STATUS_END, // The touch event ended the touch sequence.
115 TOUCH_STATUS_SYNTH_MOUSE, // The touch event was not processed, but a
116 // synthetic mouse event generated from the
117 // unused touch event was handled.
118 TOUCH_STATUS_QUEUED, // The touch event has not been processed yet, but
119 // may be processed asynchronously later. This also
120 // places a lock on touch-events (i.e. all
121 // subsequent touch-events should be sent to the
122 // current handler).
123 TOUCH_STATUS_QUEUED_END, // Similar to TOUCH_STATUS_QUEUED, except that
124 // subsequent touch-events can be sent to any
125 // handler.
126 };
127
128 // Updates the list of devices for cached properties.
129 UI_EXPORT void UpdateDeviceList();
130
131 // Get the EventType from a native event.
132 UI_EXPORT EventType EventTypeFromNative(const base::NativeEvent& native_event);
133
134 // Get the EventFlags from a native event.
135 UI_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event);
136
137 UI_EXPORT base::TimeDelta EventTimeFromNative(
138 const base::NativeEvent& native_event);
139
140 // Get the location from a native event. The coordinate system of the resultant
141 // |Point| has the origin at top-left of the "root window". The nature of
142 // this "root window" and how it maps to platform-specific drawing surfaces is
143 // defined in ui/aura/root_window.* and ui/aura/root_window_host*.
144 UI_EXPORT gfx::Point EventLocationFromNative(
145 const base::NativeEvent& native_event);
146
147 // Gets the location in native system coordinate space.
148 UI_EXPORT gfx::Point EventSystemLocationFromNative(
149 const base::NativeEvent& native_event);
150
151 #if defined(USE_X11)
152 // Returns the 'real' button for an event. The button reported in slave events
153 // does not take into account any remapping (e.g. using xmodmap), while the
154 // button reported in master events do. This is a utility function to always
155 // return the mapped button.
156 UI_EXPORT int EventButtonFromNative(const base::NativeEvent& native_event);
157 #endif
158
159 // Returns the KeyboardCode from a native event.
160 UI_EXPORT KeyboardCode KeyboardCodeFromNative(
161 const base::NativeEvent& native_event);
162
163 // Returns true if the message is a mouse event.
164 UI_EXPORT bool IsMouseEvent(const base::NativeEvent& native_event);
165
166 // Returns the flags of the button that changed during a press/release.
167 UI_EXPORT int GetChangedMouseButtonFlagsFromNative(
168 const base::NativeEvent& native_event);
169
170 // Gets the mouse wheel offset from a native event.
171 UI_EXPORT int GetMouseWheelOffset(const base::NativeEvent& native_event);
172
173 // Gets the touch id from a native event.
174 UI_EXPORT int GetTouchId(const base::NativeEvent& native_event);
175
176 // Gets the radius along the X/Y axis from a native event. Default is 1.0.
177 UI_EXPORT float GetTouchRadiusX(const base::NativeEvent& native_event);
178 UI_EXPORT float GetTouchRadiusY(const base::NativeEvent& native_event);
179
180 // Gets the angle of the major axis away from the X axis. Default is 0.0.
181 UI_EXPORT float GetTouchAngle(const base::NativeEvent& native_event);
182
183 // Gets the force from a native_event. Normalized to be [0, 1]. Default is 0.0.
184 UI_EXPORT float GetTouchForce(const base::NativeEvent& native_event);
185
186 // Gets the fling velocity from a native event. is_cancel is set to true if
187 // this was a tap down, intended to stop an ongoing fling.
188 UI_EXPORT bool GetFlingData(const base::NativeEvent& native_event,
189 float* vx,
190 float* vy,
191 bool* is_cancel);
192
193 // Returns whether this is a scroll event and optionally gets the amount to be
194 // scrolled. |x_offset| and |y_offset| can be NULL.
195 UI_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event,
196 float* x_offset,
197 float* y_offset);
198
199 UI_EXPORT bool GetGestureTimes(const base::NativeEvent& native_event,
200 double* start_time,
201 double* end_time);
202
203 // Enable/disable natural scrolling for touchpads.
204 UI_EXPORT void SetNaturalScroll(bool enabled);
205
206 // In natural scrolling enabled for touchpads?
207 UI_EXPORT bool IsNaturalScrollEnabled();
208
209 // Was this event generated by a touchpad device?
210 // The caller is responsible for ensuring that this is a mouse/touchpad event
211 // before calling this function.
212 UI_EXPORT bool IsTouchpadEvent(const base::NativeEvent& event);
213
214 // Returns true if event is noop.
215 UI_EXPORT bool IsNoopEvent(const base::NativeEvent& event);
216
217 // Creates and returns no-op event.
218 UI_EXPORT base::NativeEvent CreateNoopEvent();
219
220 #if defined(OS_WIN)
221 UI_EXPORT int GetModifiersFromACCEL(const ACCEL& accel);
222 UI_EXPORT int GetModifiersFromKeyState();
223
224 // Returns true if |message| identifies a mouse event that was generated as the
225 // result of a touch event.
226 UI_EXPORT bool IsMouseEventFromTouch(UINT message);
227 #endif
228
229 } // namespace ui
230
231 #endif // UI_BASE_EVENTS_H_
OLDNEW
« no previous file with comments | « ui/base/event_unittest.cc ('k') | ui/base/events/event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698