Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_H_ | 5 #ifndef UI_BASE_EVENTS_EVENT_H_ |
| 6 #define UI_BASE_EVENTS_EVENT_H_ | 6 #define UI_BASE_EVENTS_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 class EventTarget; |
| 23 | 23 |
| 24 class UI_EXPORT Event { | 24 class UI_EXPORT Event { |
| 25 public: | 25 public: |
| 26 virtual ~Event(); | 26 virtual ~Event(); |
| 27 | 27 |
| 28 class DispatcherApi { | 28 class DispatcherApi { |
| 29 public: | 29 public: |
| 30 explicit DispatcherApi(Event* event) : event_(event) {} | 30 explicit DispatcherApi(Event* event) : event_(event) {} |
|
Ben Goodger (Google)
2012/09/10 18:07:14
should this be private and friend class EventDispa
sadrul
2012/09/10 18:35:24
RootWindow needs to also set_target for touch-even
| |
| 31 | 31 |
| 32 void set_target(EventTarget* target) { | 32 void set_target(EventTarget* target) { |
| 33 event_->target_ = target; | 33 event_->target_ = target; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void set_phase(EventPhase phase) { event_->phase_ = phase; } | |
| 37 void set_result(int result) { | |
| 38 event_->result_ = static_cast<EventResult>(result); | |
| 39 } | |
| 40 | |
| 36 private: | 41 private: |
| 37 DispatcherApi(); | 42 DispatcherApi(); |
| 38 Event* event_; | 43 Event* event_; |
| 39 | 44 |
| 40 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); | 45 DISALLOW_COPY_AND_ASSIGN(DispatcherApi); |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 // For testing. | 48 // For testing. |
| 44 class TestApi { | 49 class TestApi { |
| 45 public: | 50 public: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 58 EventType type() const { return type_; } | 63 EventType type() const { return type_; } |
| 59 // time_stamp represents time since machine was booted. | 64 // time_stamp represents time since machine was booted. |
| 60 const base::TimeDelta& time_stamp() const { return time_stamp_; } | 65 const base::TimeDelta& time_stamp() const { return time_stamp_; } |
| 61 int flags() const { return flags_; } | 66 int flags() const { return flags_; } |
| 62 | 67 |
| 63 // This is only intended to be used externally by classes that are modifying | 68 // This is only intended to be used externally by classes that are modifying |
| 64 // events in EventFilter::PreHandleKeyEvent(). | 69 // events in EventFilter::PreHandleKeyEvent(). |
| 65 void set_flags(int flags) { flags_ = flags; } | 70 void set_flags(int flags) { flags_ = flags; } |
| 66 | 71 |
| 67 EventTarget* target() const { return target_; } | 72 EventTarget* target() const { return target_; } |
| 73 EventPhase phase() const { return phase_; } | |
| 74 EventResult result() const { return result_; } | |
| 68 | 75 |
| 69 // The following methods return true if the respective keys were pressed at | 76 // The following methods return true if the respective keys were pressed at |
| 70 // the time the event was created. | 77 // the time the event was created. |
| 71 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } | 78 bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } |
| 72 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } | 79 bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } |
| 73 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } | 80 bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } |
| 74 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } | 81 bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } |
| 75 | 82 |
| 76 bool IsKeyEvent() const { | 83 bool IsKeyEvent() const { |
| 77 return type_ == ET_KEY_PRESSED || | 84 return type_ == ET_KEY_PRESSED || |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 // Safely initializes the native event members of this class. | 171 // Safely initializes the native event members of this class. |
| 165 void Init(); | 172 void Init(); |
| 166 void InitWithNativeEvent(const base::NativeEvent& native_event); | 173 void InitWithNativeEvent(const base::NativeEvent& native_event); |
| 167 | 174 |
| 168 base::NativeEvent native_event_; | 175 base::NativeEvent native_event_; |
| 169 EventType type_; | 176 EventType type_; |
| 170 base::TimeDelta time_stamp_; | 177 base::TimeDelta time_stamp_; |
| 171 int flags_; | 178 int flags_; |
| 172 bool delete_native_event_; | 179 bool delete_native_event_; |
| 173 EventTarget* target_; | 180 EventTarget* target_; |
| 181 EventPhase phase_; | |
| 182 EventResult result_; | |
| 174 }; | 183 }; |
| 175 | 184 |
| 176 class UI_EXPORT LocatedEvent : public Event { | 185 class UI_EXPORT LocatedEvent : public Event { |
| 177 public: | 186 public: |
| 178 // For testing. | 187 // For testing. |
| 179 class TestApi : public Event::TestApi { | 188 class TestApi : public Event::TestApi { |
| 180 public: | 189 public: |
| 181 explicit TestApi(LocatedEvent* located_event) | 190 explicit TestApi(LocatedEvent* located_event) |
| 182 : Event::TestApi(located_event), | 191 : Event::TestApi(located_event), |
| 183 located_event_(located_event) {} | 192 located_event_(located_event) {} |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 // This value is stored as a bitfield because the number of touch ids varies, | 623 // This value is stored as a bitfield because the number of touch ids varies, |
| 615 // but we currently don't need more than 32 touches at a time. | 624 // but we currently don't need more than 32 touches at a time. |
| 616 const unsigned int touch_ids_bitfield_; | 625 const unsigned int touch_ids_bitfield_; |
| 617 | 626 |
| 618 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 627 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
| 619 }; | 628 }; |
| 620 | 629 |
| 621 } // namespace ui | 630 } // namespace ui |
| 622 | 631 |
| 623 #endif // UI_BASE_EVENTS_EVENT_H_ | 632 #endif // UI_BASE_EVENTS_EVENT_H_ |
| OLD | NEW |