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 // LocatedEvent, protected: | |
16 | |
17 #if !defined(USE_AURA) | |
18 LocatedEvent::LocatedEvent(const ui::NativeEvent& native_event) | |
19 : Event(native_event, | |
20 ui::EventTypeFromNative(native_event), | |
21 ui::EventFlagsFromNative(native_event)), | |
22 location_(ui::EventLocationFromNative(native_event)) { | |
23 } | |
24 #endif | |
25 | |
26 // TODO(msw): Kill this legacy constructor when we update uses. | |
27 LocatedEvent::LocatedEvent(ui::EventType type, | |
28 const gfx::Point& location, | |
29 int flags) | |
30 : Event(type, flags), | |
31 location_(location) { | |
32 } | |
33 | |
34 LocatedEvent::LocatedEvent(const LocatedEvent& model, | |
35 View* source, | |
36 View* target) | |
37 : Event(model), | |
38 location_(model.location_) { | |
39 if (target && target != source) | |
40 View::ConvertPointToView(source, target, &location_); | |
41 } | |
42 | |
43 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* root) | |
44 : Event(model), | |
45 location_(model.location_) { | |
46 View::ConvertPointFromWidget(root, &location_); | |
47 } | |
48 | |
49 //////////////////////////////////////////////////////////////////////////////// | |
50 // MouseEvent, public: | 15 // MouseEvent, public: |
51 | 16 |
| 17 #if !defined(USE_AURA) |
52 MouseEvent::MouseEvent(const ui::NativeEvent& native_event) | 18 MouseEvent::MouseEvent(const ui::NativeEvent& native_event) |
53 : LocatedEvent(native_event) { | 19 : LocatedEvent(native_event) { |
54 } | 20 } |
| 21 #endif |
55 | 22 |
56 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) | 23 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) |
57 : LocatedEvent(model, source, target) { | 24 : LocatedEvent(model, source, target) { |
58 } | 25 } |
59 | 26 |
60 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
61 // MouseWheelEvent, public: | 28 // MouseWheelEvent, public: |
62 | 29 |
63 #if !defined(USE_AURA) | 30 #if !defined(USE_AURA) |
64 MouseWheelEvent::MouseWheelEvent(const ui::NativeEvent& native_event) | 31 MouseWheelEvent::MouseWheelEvent(const ui::NativeEvent& native_event) |
(...skipping 13 matching lines...) Expand all Loading... |
78 | 45 |
79 TouchEvent::TouchEvent(ui::EventType type, | 46 TouchEvent::TouchEvent(ui::EventType type, |
80 int x, | 47 int x, |
81 int y, | 48 int y, |
82 int flags, | 49 int flags, |
83 int touch_id, | 50 int touch_id, |
84 float radius_x, | 51 float radius_x, |
85 float radius_y, | 52 float radius_y, |
86 float angle, | 53 float angle, |
87 float force) | 54 float force) |
88 : LocatedEvent(type, gfx::Point(x, y), flags), | 55 : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), flags), |
89 touch_id_(touch_id), | 56 touch_id_(touch_id), |
90 radius_x_(radius_x), | 57 radius_x_(radius_x), |
91 radius_y_(radius_y), | 58 radius_y_(radius_y), |
92 rotation_angle_(angle), | 59 rotation_angle_(angle), |
93 force_(force) { | 60 force_(force) { |
94 } | 61 } |
95 | 62 |
96 TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target) | 63 TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target) |
97 : LocatedEvent(model, source, target), | 64 : LocatedEvent(model, source, target), |
98 touch_id_(model.touch_id_), | 65 touch_id_(model.touch_id_), |
99 radius_x_(model.radius_x_), | 66 radius_x_(model.radius_x_), |
100 radius_y_(model.radius_y_), | 67 radius_y_(model.radius_y_), |
101 rotation_angle_(model.rotation_angle_), | 68 rotation_angle_(model.rotation_angle_), |
102 force_(model.force_) { | 69 force_(model.force_) { |
103 } | 70 } |
104 | 71 |
105 TouchEvent::~TouchEvent() { | 72 TouchEvent::~TouchEvent() { |
106 } | 73 } |
107 | 74 |
108 //////////////////////////////////////////////////////////////////////////////// | 75 //////////////////////////////////////////////////////////////////////////////// |
109 // TouchEvent, private: | |
110 | |
111 TouchEvent::TouchEvent(const TouchEvent& model, View* root) | |
112 : LocatedEvent(model, root), | |
113 touch_id_(model.touch_id_), | |
114 radius_x_(model.radius_x_), | |
115 radius_y_(model.radius_y_), | |
116 rotation_angle_(model.rotation_angle_), | |
117 force_(model.force_) { | |
118 } | |
119 | |
120 //////////////////////////////////////////////////////////////////////////////// | |
121 // MouseWheelEvent, public: | 76 // MouseWheelEvent, public: |
122 | 77 |
123 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
124 // This value matches windows WHEEL_DELTA. | 79 // This value matches windows WHEEL_DELTA. |
125 // static | 80 // static |
126 const int MouseWheelEvent::kWheelDelta = 120; | 81 const int MouseWheelEvent::kWheelDelta = 120; |
127 #else | 82 #else |
128 // This value matches GTK+ wheel scroll amount. | 83 // This value matches GTK+ wheel scroll amount. |
129 const int MouseWheelEvent::kWheelDelta = 53; | 84 const int MouseWheelEvent::kWheelDelta = 53; |
130 #endif | 85 #endif |
131 | 86 |
132 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
133 // GestureEvent, public: | 88 // GestureEvent, public: |
134 | 89 |
135 GestureEvent::GestureEvent(const GestureEvent& model, View* source, | 90 GestureEvent::GestureEvent(const GestureEvent& model, View* source, |
136 View* target) | 91 View* target) |
137 : LocatedEvent(model, source, target), | 92 : LocatedEvent(model, source, target), |
138 details_(model.details_) { | 93 details_(model.details_) { |
139 } | 94 } |
140 | 95 |
141 //////////////////////////////////////////////////////////////////////////////// | 96 //////////////////////////////////////////////////////////////////////////////// |
142 // GestureEvent, private: | 97 // GestureEvent, private: |
143 | 98 |
144 GestureEvent::GestureEvent(const GestureEvent& model, View* root) | |
145 : LocatedEvent(model, root), | |
146 details_(model.details_) { | |
147 } | |
148 | |
149 GestureEvent::GestureEvent(ui::EventType type, int x, int y, int flags) | 99 GestureEvent::GestureEvent(ui::EventType type, int x, int y, int flags) |
150 : LocatedEvent(type, gfx::Point(x, y), flags), | 100 : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), flags), |
151 details_(type, 0.f, 0.f) { | 101 details_(type, 0.f, 0.f) { |
152 } | 102 } |
153 | 103 |
154 GestureEvent::~GestureEvent() { | 104 GestureEvent::~GestureEvent() { |
155 } | 105 } |
156 | 106 |
157 GestureEventForTest::GestureEventForTest(ui::EventType type, | 107 GestureEventForTest::GestureEventForTest(ui::EventType type, |
158 int x, | 108 int x, |
159 int y, | 109 int y, |
160 int flags) | 110 int flags) |
161 : GestureEvent(type, x, y, flags) { | 111 : GestureEvent(type, x, y, flags) { |
162 } | 112 } |
163 | 113 |
164 } // namespace views | 114 } // namespace views |
OLD | NEW |