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

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

Issue 10908127: events: Move EventTarget into Event. (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
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_EVENTS_EVENT_CONSTANTS_EVENT_H_ 5 #ifndef UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_
6 #define UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 6 #define UI_BASE_EVENTS_EVENT_CONSTANTS_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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "ui/base/dragdrop/os_exchange_data.h" 13 #include "ui/base/dragdrop/os_exchange_data.h"
14 #include "ui/base/events/event_constants.h" 14 #include "ui/base/events/event_constants.h"
15 #include "ui/base/gestures/gesture_types.h" 15 #include "ui/base/gestures/gesture_types.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/base/ui_export.h" 17 #include "ui/base/ui_export.h"
18 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
19 19
20 namespace ui { 20 namespace ui {
21 class Transform; 21 class Transform;
22 class EventTarget;
22 23
23 class UI_EXPORT Event { 24 class UI_EXPORT Event {
24 public: 25 public:
25 virtual ~Event(); 26 virtual ~Event();
26 27
27 // For testing. 28 // For testing.
28 class TestApi { 29 class TestApi {
29 public: 30 public:
30 explicit TestApi(Event* event) : event_(event) {} 31 explicit TestApi(Event* event) : event_(event) {}
31 32
32 void set_time_stamp(const base::TimeDelta& time_stamp) { 33 void set_time_stamp(const base::TimeDelta& time_stamp) {
33 event_->time_stamp_ = time_stamp; 34 event_->time_stamp_ = time_stamp;
34 } 35 }
35 36
36 private: 37 private:
37 TestApi(); 38 TestApi();
38 Event* event_; 39 Event* event_;
39 }; 40 };
40 41
41 const base::NativeEvent& native_event() const { return native_event_; } 42 const base::NativeEvent& native_event() const { return native_event_; }
42 EventType type() const { return type_; } 43 EventType type() const { return type_; }
43 // time_stamp represents time since machine was booted. 44 // time_stamp represents time since machine was booted.
44 const base::TimeDelta& time_stamp() const { return time_stamp_; } 45 const base::TimeDelta& time_stamp() const { return time_stamp_; }
45 int flags() const { return flags_; } 46 int flags() const { return flags_; }
46 47
47 // This is only intended to be used externally by classes that are modifying 48 // This is only intended to be used externally by classes that are modifying
48 // events in EventFilter::PreHandleKeyEvent(). 49 // events in EventFilter::PreHandleKeyEvent().
49 void set_flags(int flags) { flags_ = flags; } 50 void set_flags(int flags) { flags_ = flags; }
50 51
52 void set_target(EventTarget* target) { target_ = target; }
Ben Goodger (Google) 2012/09/06 21:39:15 not sure set_target should be public... seems dang
sadrul 2012/09/06 21:44:59 aura::RootWindow also needs to set the target for
53 EventTarget* target() const { return target_; }
54
51 // The following methods return true if the respective keys were pressed at 55 // The following methods return true if the respective keys were pressed at
52 // the time the event was created. 56 // the time the event was created.
53 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } 57 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; }
54 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } 58 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; }
55 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } 59 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; }
56 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } 60 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; }
57 61
58 bool IsKeyEvent() const { 62 bool IsKeyEvent() const {
59 return type_ == ET_KEY_PRESSED || 63 return type_ == ET_KEY_PRESSED ||
60 type_ == ET_KEY_RELEASED || 64 type_ == ET_KEY_RELEASED ||
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 149
146 // Safely initializes the native event members of this class. 150 // Safely initializes the native event members of this class.
147 void Init(); 151 void Init();
148 void InitWithNativeEvent(const base::NativeEvent& native_event); 152 void InitWithNativeEvent(const base::NativeEvent& native_event);
149 153
150 base::NativeEvent native_event_; 154 base::NativeEvent native_event_;
151 EventType type_; 155 EventType type_;
152 base::TimeDelta time_stamp_; 156 base::TimeDelta time_stamp_;
153 int flags_; 157 int flags_;
154 bool delete_native_event_; 158 bool delete_native_event_;
159 EventTarget* target_;
155 }; 160 };
156 161
157 class UI_EXPORT LocatedEvent : public Event { 162 class UI_EXPORT LocatedEvent : public Event {
158 public: 163 public:
159 // For testing. 164 // For testing.
160 class TestApi : public Event::TestApi { 165 class TestApi : public Event::TestApi {
161 public: 166 public:
162 explicit TestApi(LocatedEvent* located_event) 167 explicit TestApi(LocatedEvent* located_event)
163 : Event::TestApi(located_event), 168 : Event::TestApi(located_event),
164 located_event_(located_event) {} 169 located_event_(located_event) {}
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // This value is stored as a bitfield because the number of touch ids varies, 600 // This value is stored as a bitfield because the number of touch ids varies,
596 // but we currently don't need more than 32 touches at a time. 601 // but we currently don't need more than 32 touches at a time.
597 const unsigned int touch_ids_bitfield_; 602 const unsigned int touch_ids_bitfield_;
598 603
599 DISALLOW_COPY_AND_ASSIGN(GestureEvent); 604 DISALLOW_COPY_AND_ASSIGN(GestureEvent);
600 }; 605 };
601 606
602 } // namespace ui 607 } // namespace ui
603 608
604 #endif // UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_ 609 #endif // UI_BASE_EVENTS_EVENT_CONSTANTS_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698