| 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 #include "views/events/event.h" | 5 #include "views/events/event.h" |
| 6 | 6 |
| 7 #include "views/view.h" | 7 #include "views/view.h" |
| 8 #include "views/widget/root_view.h" | 8 #include "views/widget/root_view.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 : native_event_2_(native_event_2), | 31 : native_event_2_(native_event_2), |
| 32 type_(type), | 32 type_(type), |
| 33 time_stamp_(base::Time::NowFromSystemTime()), | 33 time_stamp_(base::Time::NowFromSystemTime()), |
| 34 flags_(flags) { | 34 flags_(flags) { |
| 35 InitWithNativeEvent2(native_event_2, from_native); | 35 InitWithNativeEvent2(native_event_2, from_native); |
| 36 } | 36 } |
| 37 | 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| 39 // LocatedEvent, protected: | 39 // LocatedEvent, protected: |
| 40 | 40 |
| 41 // TODO(msw): Kill this legacy constructor when we update uses. |
| 41 LocatedEvent::LocatedEvent(ui::EventType type, const gfx::Point& location, | 42 LocatedEvent::LocatedEvent(ui::EventType type, const gfx::Point& location, |
| 42 int flags) | 43 int flags) |
| 43 : Event(type, flags), | 44 : Event(type, flags), |
| 44 location_(location) { | 45 location_(location) { |
| 45 } | 46 } |
| 46 | 47 |
| 47 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* source, | 48 LocatedEvent::LocatedEvent(const LocatedEvent& model, View* source, |
| 48 View* target) | 49 View* target) |
| 49 : Event(model), | 50 : Event(model), |
| 50 location_(model.location_) { | 51 location_(model.location_) { |
| 51 if (target) | 52 if (target) |
| 52 View::ConvertPointToView(source, target, &location_); | 53 View::ConvertPointToView(source, target, &location_); |
| 53 } | 54 } |
| 54 | 55 |
| 55 //////////////////////////////////////////////////////////////////////////////// | |
| 56 // LocatedEvent, private: | |
| 57 | |
| 58 LocatedEvent::LocatedEvent(const LocatedEvent& model, RootView* root) | 56 LocatedEvent::LocatedEvent(const LocatedEvent& model, RootView* root) |
| 59 : Event(model), | 57 : Event(model), |
| 60 location_(model.location_) { | 58 location_(model.location_) { |
| 61 View::ConvertPointFromWidget(root, &location_); | 59 View::ConvertPointFromWidget(root, &location_); |
| 62 } | 60 } |
| 63 | 61 |
| 64 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 65 // KeyEvent, public: | 63 // KeyEvent, public: |
| 66 | 64 |
| 67 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, | 65 KeyEvent::KeyEvent(ui::EventType type, ui::KeyboardCode key_code, |
| 68 int event_flags) | 66 int event_flags) |
| 69 : Event(type, event_flags), | 67 : Event(type, event_flags), |
| 70 key_code_(key_code) { | 68 key_code_(key_code) { |
| 71 } | 69 } |
| 72 | 70 |
| 73 //////////////////////////////////////////////////////////////////////////////// | 71 //////////////////////////////////////////////////////////////////////////////// |
| 74 // MouseEvent, public: | 72 // MouseEvent, public: |
| 75 | 73 |
| 74 MouseEvent::MouseEvent(NativeEvent native_event) |
| 75 : LocatedEvent(native_event) { |
| 76 } |
| 77 |
| 78 // TODO(msw): Kill this legacy constructor when we update uses. |
| 76 MouseEvent::MouseEvent(ui::EventType type, | 79 MouseEvent::MouseEvent(ui::EventType type, |
| 77 View* from, | 80 View* source, |
| 78 View* to, | 81 View* target, |
| 79 const gfx::Point &l, | 82 const gfx::Point &l, |
| 80 int flags) | 83 int flags) |
| 81 : LocatedEvent(MouseEvent(type, l.x(), l.y(), flags), from, to) { | 84 : LocatedEvent(MouseEvent(type, l.x(), l.y(), flags), source, target) { |
| 82 } | 85 } |
| 83 | 86 |
| 84 MouseEvent::MouseEvent(const MouseEvent& model, View* from, View* to) | 87 MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) |
| 85 : LocatedEvent(model, from, to) { | 88 : LocatedEvent(model, source, target) { |
| 86 } | 89 } |
| 87 | 90 |
| 88 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
| 89 // TouchEvent, public: | 92 // TouchEvent, public: |
| 90 | 93 |
| 91 #if defined(TOUCH_UI) | 94 #if defined(TOUCH_UI) |
| 92 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, | 95 TouchEvent::TouchEvent(ui::EventType type, int x, int y, int flags, |
| 93 int touch_id) | 96 int touch_id) |
| 94 : LocatedEvent(type, gfx::Point(x, y), flags), | 97 : LocatedEvent(type, gfx::Point(x, y), flags), |
| 95 touch_id_(touch_id) { | 98 touch_id_(touch_id) { |
| 96 } | 99 } |
| 97 | 100 |
| 98 | 101 |
| 99 TouchEvent::TouchEvent(ui::EventType type, | 102 TouchEvent::TouchEvent(ui::EventType type, |
| 100 View* from, | 103 View* source, |
| 101 View* to, | 104 View* target, |
| 102 const gfx::Point& l, | 105 const gfx::Point& l, |
| 103 int flags, | 106 int flags, |
| 104 int touch_id) | 107 int touch_id) |
| 105 : LocatedEvent(TouchEvent(type, l.x(), l.y(), flags, touch_id), from, to), | 108 : LocatedEvent(TouchEvent(type, l.x(), l.y(), flags, touch_id), source, |
| 109 target), |
| 106 touch_id_(touch_id) { | 110 touch_id_(touch_id) { |
| 107 } | 111 } |
| 108 | 112 |
| 109 TouchEvent::TouchEvent(const TouchEvent& model, View* from, View* to) | 113 TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target) |
| 110 : LocatedEvent(model, from, to), | 114 : LocatedEvent(model, source, target), |
| 111 touch_id_(model.touch_id_) { | 115 touch_id_(model.touch_id_) { |
| 112 } | 116 } |
| 113 #endif | 117 #endif |
| 114 | 118 |
| 115 } // namespace views | 119 } // namespace views |
| OLD | NEW |