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

Side by Side Diff: ui/views/events/event.h

Issue 10824295: Rid the world of the last of views::Event types: TouchEvent, GestureEvent, MouseWheelEvent, ScrollE… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/views/controls/webview/web_dialog_view.cc ('k') | ui/views/events/event.cc » ('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
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #ifndef UI_VIEWS_EVENTS_EVENT_H_
7 #define UI_VIEWS_EVENTS_EVENT_H_
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/logging.h"
12 #include "base/time.h"
13 #include "ui/base/event.h"
14 #include "ui/base/events.h"
15 #include "ui/base/gestures/gesture_types.h"
16 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/gfx/point.h"
18 #include "ui/views/views_export.h"
19
20 namespace ui {
21 class Event;
22 class OSExchangeData;
23 }
24
25
26 namespace views {
27
28 class View;
29
30 namespace internal {
31 class RootView;
32 }
33
34 ////////////////////////////////////////////////////////////////////////////////
35 //
36 // TouchEvent class
37 //
38 // A touch event is generated by touch screen and advanced track
39 // pad devices. There is a deliberate direct correspondence between
40 // TouchEvent and PlatformTouchPoint.
41 //
42 ////////////////////////////////////////////////////////////////////////////////
43 class VIEWS_EXPORT TouchEvent : public ui::LocatedEvent {
44 public:
45 explicit TouchEvent(const ui::NativeEvent& native_event);
46
47 // Create a new touch event.
48 TouchEvent(ui::EventType type,
49 int x,
50 int y,
51 int flags,
52 int touch_id,
53 float radius_x,
54 float radius_y,
55 float angle,
56 float force);
57
58 // Create a new TouchEvent which is identical to the provided model.
59 // If source / target views are provided, the model location will be converted
60 // from |source| coordinate system to |target| coordinate system.
61 TouchEvent(const TouchEvent& model, View* source, View* target);
62
63 virtual ~TouchEvent();
64
65 int identity() const { return touch_id_; }
66
67 float radius_x() const { return radius_x_; }
68 float radius_y() const { return radius_y_; }
69 float rotation_angle() const { return rotation_angle_; }
70 float force() const { return force_; }
71
72 private:
73 // The identity (typically finger) of the touch starting at 0 and incrementing
74 // for each separable additional touch that the hardware can detect.
75 const int touch_id_;
76
77 // Radius of the X (major) axis of the touch ellipse. 1.0 if unknown.
78 const float radius_x_;
79
80 // Radius of the Y (minor) axis of the touch ellipse. 1.0 if unknown.
81 const float radius_y_;
82
83 // Angle of the major axis away from the X axis. Default 0.0.
84 const float rotation_angle_;
85
86 // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0.
87 const float force_;
88
89 DISALLOW_COPY_AND_ASSIGN(TouchEvent);
90 };
91
92 class ScrollEvent;
93
94 ////////////////////////////////////////////////////////////////////////////////
95 //
96 // MouseWheelEvent class
97 //
98 // A MouseWheelEvent is used to propagate mouse wheel user events.
99 // Note: e.GetOffset() > 0 means scroll up / left.
100 //
101 ////////////////////////////////////////////////////////////////////////////////
102 class VIEWS_EXPORT MouseWheelEvent : public ui::MouseEvent {
103 public:
104 // See |offset| for details.
105 static const int kWheelDelta;
106
107 explicit MouseWheelEvent(const ui::NativeEvent& native_event);
108 explicit MouseWheelEvent(const ScrollEvent& scroll_event);
109
110 // The amount to scroll. This is in multiples of kWheelDelta.
111 int offset() const { return offset_; }
112
113 private:
114 int offset_;
115
116 DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent);
117 };
118
119 ////////////////////////////////////////////////////////////////////////////////
120 //
121 // DropTargetEvent class
122 //
123 // A DropTargetEvent is sent to the view the mouse is over during a drag and
124 // drop operation.
125 //
126 ////////////////////////////////////////////////////////////////////////////////
127 class VIEWS_EXPORT DropTargetEvent : public ui::LocatedEvent {
128 public:
129 DropTargetEvent(const ui::OSExchangeData& data,
130 int x,
131 int y,
132 int source_operations)
133 : LocatedEvent(
134 ui::ET_DROP_TARGET_EVENT, gfx::Point(x, y), gfx::Point(x, y), 0),
135 data_(data),
136 source_operations_(source_operations) {
137 // TODO(msw): Hook up key state flags for CTRL + drag and drop, etc.
138 }
139
140 const ui::OSExchangeData& data() const { return data_; }
141 int source_operations() const { return source_operations_; }
142
143 private:
144 // Data associated with the drag/drop session.
145 const ui::OSExchangeData& data_;
146
147 // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
148 int source_operations_;
149
150 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
151 };
152
153 class VIEWS_EXPORT ScrollEvent : public ui::MouseEvent {
154 public:
155 explicit ScrollEvent(const ui::NativeEvent& native_event);
156
157 float x_offset() const { return x_offset_; }
158 float y_offset() const { return y_offset_; }
159
160 private:
161 float x_offset_;
162 float y_offset_;
163
164 DISALLOW_COPY_AND_ASSIGN(ScrollEvent);
165 };
166
167 ////////////////////////////////////////////////////////////////////////////////
168 // GestureEvent class
169 //
170 ////////////////////////////////////////////////////////////////////////////////
171 class VIEWS_EXPORT GestureEvent : public ui::LocatedEvent {
172 public:
173 explicit GestureEvent(const ui::NativeEvent& native_event);
174
175 // Create a new GestureEvent which is identical to the provided model.
176 // If source / target views are provided, the model location will be converted
177 // from |source| coordinate system to |target| coordinate system.
178 GestureEvent(const GestureEvent& model, View* source, View* target);
179
180 virtual ~GestureEvent();
181
182 const ui::GestureEventDetails& details() const { return details_; }
183
184 protected:
185 GestureEvent(ui::EventType type, int x, int y, int flags);
186
187 private:
188 ui::GestureEventDetails details_;
189
190 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
191 };
192
193 class VIEWS_EXPORT GestureEventForTest : public GestureEvent {
194 public:
195 GestureEventForTest(ui::EventType type, int x, int y, int flags);
196
197 private:
198 DISALLOW_COPY_AND_ASSIGN(GestureEventForTest);
199 };
200
201 #if defined(OS_WIN)
202 int GetModifiersFromKeyState();
203 #endif
204
205 } // namespace views
206
207 #endif // UI_VIEWS_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/views/controls/webview/web_dialog_view.cc ('k') | ui/views/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698