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

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

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (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/tree/tree_view_views.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
1 1
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 #ifndef UI_VIEWS_EVENTS_EVENT_H_ 6 #ifndef UI_VIEWS_EVENTS_EVENT_H_
7 #define UI_VIEWS_EVENTS_EVENT_H_ 7 #define UI_VIEWS_EVENTS_EVENT_H_
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 15 matching lines...) Expand all
26 namespace views { 26 namespace views {
27 27
28 class View; 28 class View;
29 29
30 namespace internal { 30 namespace internal {
31 class RootView; 31 class RootView;
32 } 32 }
33 33
34 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
35 // 35 //
36 // MouseEvent class
37 //
38 // A mouse event is used for any input event related to the mouse.
39 //
40 ////////////////////////////////////////////////////////////////////////////////
41 class VIEWS_EXPORT MouseEvent : public ui::LocatedEvent {
42 public:
43 explicit MouseEvent(const ui::NativeEvent& native_event);
44 // Create a new MouseEvent which is identical to the provided model.
45 // If source / target views are provided, the model location will be converted
46 // from |source| coordinate system to |target| coordinate system.
47 MouseEvent(const MouseEvent& model, View* source, View* target);
48
49 // TODO(msw): Kill this legacy constructor when we update uses.
50 // Create a new mouse event
51 MouseEvent(ui::EventType type, int x, int y, int flags)
52 : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), flags) {
53 }
54
55 // Conveniences to quickly test what button is down
56 bool IsOnlyLeftMouseButton() const {
57 return (flags() & ui::EF_LEFT_MOUSE_BUTTON) &&
58 !(flags() & (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON));
59 }
60
61 bool IsLeftMouseButton() const {
62 return (flags() & ui::EF_LEFT_MOUSE_BUTTON) != 0;
63 }
64
65 bool IsOnlyMiddleMouseButton() const {
66 return (flags() & ui::EF_MIDDLE_MOUSE_BUTTON) &&
67 !(flags() & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON));
68 }
69
70 bool IsMiddleMouseButton() const {
71 return (flags() & ui::EF_MIDDLE_MOUSE_BUTTON) != 0;
72 }
73
74 bool IsOnlyRightMouseButton() const {
75 return (flags() & ui::EF_RIGHT_MOUSE_BUTTON) &&
76 !(flags() & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON));
77 }
78
79 bool IsRightMouseButton() const {
80 return (flags() & ui::EF_RIGHT_MOUSE_BUTTON) != 0;
81 }
82 };
83
84 ////////////////////////////////////////////////////////////////////////////////
85 //
86 // TouchEvent class 36 // TouchEvent class
87 // 37 //
88 // A touch event is generated by touch screen and advanced track 38 // A touch event is generated by touch screen and advanced track
89 // pad devices. There is a deliberate direct correspondence between 39 // pad devices. There is a deliberate direct correspondence between
90 // TouchEvent and PlatformTouchPoint. 40 // TouchEvent and PlatformTouchPoint.
91 // 41 //
92 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
93 class VIEWS_EXPORT TouchEvent : public ui::LocatedEvent { 43 class VIEWS_EXPORT TouchEvent : public ui::LocatedEvent {
94 public: 44 public:
95 explicit TouchEvent(const ui::NativeEvent& native_event); 45 explicit TouchEvent(const ui::NativeEvent& native_event);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 class ScrollEvent; 92 class ScrollEvent;
143 93
144 //////////////////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////////////
145 // 95 //
146 // MouseWheelEvent class 96 // MouseWheelEvent class
147 // 97 //
148 // A MouseWheelEvent is used to propagate mouse wheel user events. 98 // A MouseWheelEvent is used to propagate mouse wheel user events.
149 // Note: e.GetOffset() > 0 means scroll up / left. 99 // Note: e.GetOffset() > 0 means scroll up / left.
150 // 100 //
151 //////////////////////////////////////////////////////////////////////////////// 101 ////////////////////////////////////////////////////////////////////////////////
152 class VIEWS_EXPORT MouseWheelEvent : public MouseEvent { 102 class VIEWS_EXPORT MouseWheelEvent : public ui::MouseEvent {
153 public: 103 public:
154 // See |offset| for details. 104 // See |offset| for details.
155 static const int kWheelDelta; 105 static const int kWheelDelta;
156 106
157 explicit MouseWheelEvent(const ui::NativeEvent& native_event); 107 explicit MouseWheelEvent(const ui::NativeEvent& native_event);
158 explicit MouseWheelEvent(const ScrollEvent& scroll_event); 108 explicit MouseWheelEvent(const ScrollEvent& scroll_event);
159 109
160 // The amount to scroll. This is in multiples of kWheelDelta. 110 // The amount to scroll. This is in multiples of kWheelDelta.
161 int offset() const { return offset_; } 111 int offset() const { return offset_; }
162 112
(...skipping 30 matching lines...) Expand all
193 private: 143 private:
194 // Data associated with the drag/drop session. 144 // Data associated with the drag/drop session.
195 const ui::OSExchangeData& data_; 145 const ui::OSExchangeData& data_;
196 146
197 // Bitmask of supported ui::DragDropTypes::DragOperation by the source. 147 // Bitmask of supported ui::DragDropTypes::DragOperation by the source.
198 int source_operations_; 148 int source_operations_;
199 149
200 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); 150 DISALLOW_COPY_AND_ASSIGN(DropTargetEvent);
201 }; 151 };
202 152
203 class VIEWS_EXPORT ScrollEvent : public MouseEvent { 153 class VIEWS_EXPORT ScrollEvent : public ui::MouseEvent {
204 public: 154 public:
205 explicit ScrollEvent(const ui::NativeEvent& native_event); 155 explicit ScrollEvent(const ui::NativeEvent& native_event);
206 156
207 float x_offset() const { return x_offset_; } 157 float x_offset() const { return x_offset_; }
208 float y_offset() const { return y_offset_; } 158 float y_offset() const { return y_offset_; }
209 159
210 private: 160 private:
211 float x_offset_; 161 float x_offset_;
212 float y_offset_; 162 float y_offset_;
213 163
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 DISALLOW_COPY_AND_ASSIGN(GestureEventForTest); 198 DISALLOW_COPY_AND_ASSIGN(GestureEventForTest);
249 }; 199 };
250 200
251 #if defined(OS_WIN) 201 #if defined(OS_WIN)
252 int GetModifiersFromKeyState(); 202 int GetModifiersFromKeyState();
253 #endif 203 #endif
254 204
255 } // namespace views 205 } // namespace views
256 206
257 #endif // UI_VIEWS_EVENTS_EVENT_H_ 207 #endif // UI_VIEWS_EVENTS_EVENT_H_
OLDNEW
« no previous file with comments | « ui/views/controls/tree/tree_view_views.cc ('k') | ui/views/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698