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 #include "ui/views/events/event.h" | 5 #include "ui/views/events/event.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/keycodes/keyboard_code_conversion.h" | 8 #include "ui/base/keycodes/keyboard_code_conversion.h" |
9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
10 #include "ui/views/widget/root_view.h" | 10 #include "ui/views/widget/root_view.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
15 // Event, protected: | |
16 | |
17 Event::Event(ui::EventType type, int flags) | |
18 : type_(type), | |
19 time_stamp_(base::Time::NowFromSystemTime()), | |
20 flags_(flags) { | |
21 // Safely initialize the pointer/struct to null/empty. | |
22 memset(&native_event_, 0, sizeof(native_event_)); | |
23 } | |
24 | |
25 Event::Event(const NativeEvent& native_event, ui::EventType type, int flags) | |
26 : native_event_(native_event), | |
27 type_(type), | |
28 time_stamp_(base::Time::NowFromSystemTime()), | |
29 flags_(flags) { | |
30 } | |
31 | |
32 //////////////////////////////////////////////////////////////////////////////// | |
33 // LocatedEvent, protected: | 15 // LocatedEvent, protected: |
34 | 16 |
35 #if !defined(USE_AURA) | 17 #if !defined(USE_AURA) |
36 LocatedEvent::LocatedEvent(const NativeEvent& native_event) | 18 LocatedEvent::LocatedEvent(const ui::NativeEvent& native_event) |
37 : Event(native_event, | 19 : Event(native_event, |
38 ui::EventTypeFromNative(native_event), | 20 ui::EventTypeFromNative(native_event), |
39 ui::EventFlagsFromNative(native_event)), | 21 ui::EventFlagsFromNative(native_event)), |
40 location_(ui::EventLocationFromNative(native_event)) { | 22 location_(ui::EventLocationFromNative(native_event)) { |
41 } | 23 } |
42 #endif | 24 #endif |
43 | 25 |
44 // TODO(msw): Kill this legacy constructor when we update uses. | 26 // TODO(msw): Kill this legacy constructor when we update uses. |
45 LocatedEvent::LocatedEvent(ui::EventType type, | 27 LocatedEvent::LocatedEvent(ui::EventType type, |
46 const gfx::Point& location, | 28 const gfx::Point& location, |
(...skipping 13 matching lines...) Expand all Loading... |
60 | 42 |
61 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* root) | 43 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* root) |
62 : Event(model), | 44 : Event(model), |
63 location_(model.location_) { | 45 location_(model.location_) { |
64 View::ConvertPointFromWidget(root, &location_); | 46 View::ConvertPointFromWidget(root, &location_); |
65 } | 47 } |
66 | 48 |
67 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
68 // MouseEvent, public: | 50 // MouseEvent, public: |
69 | 51 |
70 MouseEvent::MouseEvent(const NativeEvent& native_event) | 52 MouseEvent::MouseEvent(const ui::NativeEvent& native_event) |
71 : LocatedEvent(native_event) { | 53 : LocatedEvent(native_event) { |
72 } | 54 } |
73 | 55 |
74 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) | 56 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) |
75 : LocatedEvent(model, source, target) { | 57 : LocatedEvent(model, source, target) { |
76 } | 58 } |
77 | 59 |
78 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
79 // MouseWheelEvent, public: | 61 // MouseWheelEvent, public: |
80 | 62 |
81 #if !defined(USE_AURA) | 63 #if !defined(USE_AURA) |
82 MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event) | 64 MouseWheelEvent::MouseWheelEvent(const ui::NativeEvent& native_event) |
83 : MouseEvent(native_event), | 65 : MouseEvent(native_event), |
84 offset_(ui::GetMouseWheelOffset(native_event)) { | 66 offset_(ui::GetMouseWheelOffset(native_event)) { |
85 } | 67 } |
86 #endif | 68 #endif |
87 | 69 |
88 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) | 70 MouseWheelEvent::MouseWheelEvent(const ScrollEvent& scroll_event) |
89 : MouseEvent(scroll_event.native_event()), | 71 : MouseEvent(scroll_event), |
90 offset_(scroll_event.y_offset()) { | 72 offset_(scroll_event.y_offset()) { |
91 set_type(ui::ET_MOUSEWHEEL); | 73 set_type(ui::ET_MOUSEWHEEL); |
92 } | 74 } |
93 | 75 |
94 //////////////////////////////////////////////////////////////////////////////// | 76 //////////////////////////////////////////////////////////////////////////////// |
95 // TouchEvent, public: | 77 // TouchEvent, public: |
96 | 78 |
97 TouchEvent::TouchEvent(ui::EventType type, | 79 TouchEvent::TouchEvent(ui::EventType type, |
98 int x, | 80 int x, |
99 int y, | 81 int y, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 155 } |
174 | 156 |
175 GestureEventForTest::GestureEventForTest(ui::EventType type, | 157 GestureEventForTest::GestureEventForTest(ui::EventType type, |
176 int x, | 158 int x, |
177 int y, | 159 int y, |
178 int flags) | 160 int flags) |
179 : GestureEvent(type, x, y, flags) { | 161 : GestureEvent(type, x, y, flags) { |
180 } | 162 } |
181 | 163 |
182 } // namespace views | 164 } // namespace views |
OLD | NEW |