OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_AURA_EVENT_H_ | 5 #ifndef UI_AURA_EVENT_H_ |
6 #define UI_AURA_EVENT_H_ | 6 #define UI_AURA_EVENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/event_types.h" |
10 #include "base/time.h" | 11 #include "base/time.h" |
11 #include "ui/aura/aura_export.h" | 12 #include "ui/aura/aura_export.h" |
12 #include "ui/base/events.h" | 13 #include "ui/base/events.h" |
13 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
14 #include "ui/gfx/point.h" | 15 #include "ui/gfx/point.h" |
15 | 16 |
16 namespace aura { | 17 namespace aura { |
17 | 18 |
18 class Window; | 19 class Window; |
19 | 20 |
20 class AURA_EXPORT Event { | 21 class AURA_EXPORT Event { |
21 public: | 22 public: |
22 const ui::NativeEvent& native_event() const { return native_event_; } | 23 const base::NativeEvent& native_event() const { return native_event_; } |
23 ui::EventType type() const { return type_; } | 24 ui::EventType type() const { return type_; } |
24 const base::Time& time_stamp() const { return time_stamp_; } | 25 const base::Time& time_stamp() const { return time_stamp_; } |
25 int flags() const { return flags_; } | 26 int flags() const { return flags_; } |
26 | 27 |
27 protected: | 28 protected: |
28 Event(ui::EventType type, int flags); | 29 Event(ui::EventType type, int flags); |
29 Event(const ui::NativeEvent& native_event, ui::EventType type, int flags); | 30 Event(const base::NativeEvent& native_event, ui::EventType type, int flags); |
30 Event(const Event& copy); | 31 Event(const Event& copy); |
31 void set_type(ui::EventType type) { type_ = type; } | 32 void set_type(ui::EventType type) { type_ = type; } |
32 | 33 |
33 private: | 34 private: |
34 void operator=(const Event&); | 35 void operator=(const Event&); |
35 | 36 |
36 // Safely initializes the native event members of this class. | 37 // Safely initializes the native event members of this class. |
37 void Init(); | 38 void Init(); |
38 void InitWithNativeEvent(const ui::NativeEvent& native_event); | 39 void InitWithNativeEvent(const base::NativeEvent& native_event); |
39 | 40 |
40 ui::NativeEvent native_event_; | 41 base::NativeEvent native_event_; |
41 ui::EventType type_; | 42 ui::EventType type_; |
42 base::Time time_stamp_; | 43 base::Time time_stamp_; |
43 int flags_; | 44 int flags_; |
44 }; | 45 }; |
45 | 46 |
46 class AURA_EXPORT LocatedEvent : public Event { | 47 class AURA_EXPORT LocatedEvent : public Event { |
47 public: | 48 public: |
48 int x() const { return location_.x(); } | 49 int x() const { return location_.x(); } |
49 int y() const { return location_.y(); } | 50 int y() const { return location_.y(); } |
50 gfx::Point location() const { return location_; } | 51 gfx::Point location() const { return location_; } |
51 | 52 |
52 protected: | 53 protected: |
53 explicit LocatedEvent(const ui::NativeEvent& native_event); | 54 explicit LocatedEvent(const base::NativeEvent& native_event); |
54 | 55 |
55 // Create a new LocatedEvent which is identical to the provided model. | 56 // Create a new LocatedEvent which is identical to the provided model. |
56 // If source / target windows are provided, the model location will be | 57 // If source / target windows are provided, the model location will be |
57 // converted from |source| coordinate system to |target| coordinate system. | 58 // converted from |source| coordinate system to |target| coordinate system. |
58 LocatedEvent(const LocatedEvent& model, Window* source, Window* target); | 59 LocatedEvent(const LocatedEvent& model, Window* source, Window* target); |
59 | 60 |
60 // Used for synthetic events in testing. | 61 // Used for synthetic events in testing. |
61 LocatedEvent(ui::EventType type, const gfx::Point& location, int flags); | 62 LocatedEvent(ui::EventType type, const gfx::Point& location, int flags); |
62 | 63 |
63 gfx::Point location_; | 64 gfx::Point location_; |
64 | 65 |
65 private: | 66 private: |
66 DISALLOW_COPY_AND_ASSIGN(LocatedEvent); | 67 DISALLOW_COPY_AND_ASSIGN(LocatedEvent); |
67 }; | 68 }; |
68 | 69 |
69 class AURA_EXPORT MouseEvent : public LocatedEvent { | 70 class AURA_EXPORT MouseEvent : public LocatedEvent { |
70 public: | 71 public: |
71 explicit MouseEvent(const ui::NativeEvent& native_event); | 72 explicit MouseEvent(const base::NativeEvent& native_event); |
72 | 73 |
73 // Create a new MouseEvent which is identical to the provided model. | 74 // Create a new MouseEvent which is identical to the provided model. |
74 // If source / target windows are provided, the model location will be | 75 // If source / target windows are provided, the model location will be |
75 // converted from |source| coordinate system to |target| coordinate system. | 76 // converted from |source| coordinate system to |target| coordinate system. |
76 MouseEvent(const MouseEvent& model, Window* source, Window* target); | 77 MouseEvent(const MouseEvent& model, Window* source, Window* target); |
77 MouseEvent(const MouseEvent& model, | 78 MouseEvent(const MouseEvent& model, |
78 Window* source, | 79 Window* source, |
79 Window* target, | 80 Window* target, |
80 ui::EventType type); | 81 ui::EventType type); |
81 | 82 |
82 // Used for synthetic events in testing. | 83 // Used for synthetic events in testing. |
83 MouseEvent(ui::EventType type, const gfx::Point& location, int flags); | 84 MouseEvent(ui::EventType type, const gfx::Point& location, int flags); |
84 | 85 |
85 private: | 86 private: |
86 DISALLOW_COPY_AND_ASSIGN(MouseEvent); | 87 DISALLOW_COPY_AND_ASSIGN(MouseEvent); |
87 }; | 88 }; |
88 | 89 |
89 class AURA_EXPORT KeyEvent : public Event { | 90 class AURA_EXPORT KeyEvent : public Event { |
90 public: | 91 public: |
91 explicit KeyEvent(const ui::NativeEvent& native_event); | 92 explicit KeyEvent(const base::NativeEvent& native_event); |
92 | 93 |
93 // Used for synthetic events in testing. | 94 // Used for synthetic events in testing. |
94 KeyEvent(ui::EventType type, | 95 KeyEvent(ui::EventType type, |
95 ui::KeyboardCode key_code, | 96 ui::KeyboardCode key_code, |
96 int flags); | 97 int flags); |
97 | 98 |
98 ui::KeyboardCode key_code() const { return key_code_; } | 99 ui::KeyboardCode key_code() const { return key_code_; } |
99 | 100 |
100 private: | 101 private: |
101 ui::KeyboardCode key_code_; | 102 ui::KeyboardCode key_code_; |
102 }; | 103 }; |
103 | 104 |
104 } // namespace aura | 105 } // namespace aura |
105 | 106 |
106 #endif // UI_AURA_EVENT_H_ | 107 #endif // UI_AURA_EVENT_H_ |
OLD | NEW |