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

Side by Side Diff: ui/base/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/app_list/search_result_list_view.cc ('k') | ui/views/color_chooser/color_chooser_view.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_BASE_EVENT_H_ 5 #ifndef UI_BASE_EVENT_H_
6 #define UI_BASE_EVENT_H_ 6 #define UI_BASE_EVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/event_types.h" 10 #include "base/event_types.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 set_type(type); 200 set_type(type);
201 set_flags(flags); 201 set_flags(flags);
202 } 202 }
203 203
204 // Used for synthetic events in testing and by the gesture recognizer. 204 // Used for synthetic events in testing and by the gesture recognizer.
205 MouseEvent(EventType type, 205 MouseEvent(EventType type,
206 const gfx::Point& location, 206 const gfx::Point& location,
207 const gfx::Point& root_location, 207 const gfx::Point& root_location,
208 int flags); 208 int flags);
209 209
210 // Conveniences to quickly test what button is down
211 bool IsOnlyLeftMouseButton() const {
212 return (flags() & ui::EF_LEFT_MOUSE_BUTTON) &&
213 !(flags() & (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON));
214 }
215
216 bool IsLeftMouseButton() const {
217 return (flags() & ui::EF_LEFT_MOUSE_BUTTON) != 0;
218 }
219
220 bool IsOnlyMiddleMouseButton() const {
221 return (flags() & ui::EF_MIDDLE_MOUSE_BUTTON) &&
222 !(flags() & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON));
223 }
224
225 bool IsMiddleMouseButton() const {
226 return (flags() & ui::EF_MIDDLE_MOUSE_BUTTON) != 0;
227 }
228
229 bool IsOnlyRightMouseButton() const {
230 return (flags() & ui::EF_RIGHT_MOUSE_BUTTON) &&
231 !(flags() & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON));
232 }
233
234 bool IsRightMouseButton() const {
235 return (flags() & ui::EF_RIGHT_MOUSE_BUTTON) != 0;
236 }
237
210 // Compares two mouse down events and returns true if the second one should 238 // Compares two mouse down events and returns true if the second one should
211 // be considered a repeat of the first. 239 // be considered a repeat of the first.
212 static bool IsRepeatedClickEvent( 240 static bool IsRepeatedClickEvent(
213 const MouseEvent& event1, 241 const MouseEvent& event1,
214 const MouseEvent& event2); 242 const MouseEvent& event2);
215 243
216 // Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise. 244 // Get the click count. Can be 1, 2 or 3 for mousedown messages, 0 otherwise.
217 int GetClickCount() const; 245 int GetClickCount() const;
218 246
219 // Set the click count for a mousedown message. Can be 1, 2 or 3. 247 // Set the click count for a mousedown message. Can be 1, 2 or 3.
220 void SetClickCount(int click_count); 248 void SetClickCount(int click_count);
221 249
222 private: 250 protected:
223 explicit MouseEvent(const MouseEvent& model); 251 explicit MouseEvent(const MouseEvent& model);
224 252
253 private:
225 gfx::Point root_location_; 254 gfx::Point root_location_;
226 255
227 static MouseEvent* last_click_event_; 256 static MouseEvent* last_click_event_;
228 // Returns the repeat count based on the previous mouse click, if it is 257 // Returns the repeat count based on the previous mouse click, if it is
229 // recent enough and within a small enough distance. 258 // recent enough and within a small enough distance.
230 static int GetRepeatCount(const MouseEvent& click_event); 259 static int GetRepeatCount(const MouseEvent& click_event);
231 }; 260 };
232 261
233 class UI_EXPORT TouchEvent : public LocatedEvent { 262 class UI_EXPORT TouchEvent : public LocatedEvent {
234 public: 263 public:
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // This value is stored as a bitfield because the number of touch ids varies, 475 // This value is stored as a bitfield because the number of touch ids varies,
447 // but we currently don't need more than 32 touches at a time. 476 // but we currently don't need more than 32 touches at a time.
448 const unsigned int touch_ids_bitfield_; 477 const unsigned int touch_ids_bitfield_;
449 478
450 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 479 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
451 }; 480 };
452 481
453 } // namespace ui 482 } // namespace ui
454 483
455 #endif // UI_BASE_EVENT_H_ 484 #endif // UI_BASE_EVENT_H_
OLDNEW
« no previous file with comments | « ui/app_list/search_result_list_view.cc ('k') | ui/views/color_chooser/color_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698