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_EVENT_H_ | 5 #ifndef UI_BASE_EVENT_H_ |
6 #define UI_BASE_EVENT_H_ | 6 #define UI_BASE_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" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 LocatedEvent* located_event_; | 129 LocatedEvent* located_event_; |
130 }; | 130 }; |
131 | 131 |
132 virtual ~LocatedEvent(); | 132 virtual ~LocatedEvent(); |
133 | 133 |
134 int x() const { return location_.x(); } | 134 int x() const { return location_.x(); } |
135 int y() const { return location_.y(); } | 135 int y() const { return location_.y(); } |
136 gfx::Point location() const { return location_; } | 136 gfx::Point location() const { return location_; } |
137 gfx::Point root_location() const { return root_location_; } | 137 gfx::Point root_location() const { return root_location_; } |
138 | 138 |
139 bool valid_system_location() const { return valid_system_location_; } | |
140 void set_system_location(const gfx::Point& loc) { | |
141 valid_system_location_ = true; | |
142 system_location_ = loc; | |
143 } | |
144 const gfx::Point& system_location() const { return system_location_; } | |
145 | |
139 // Applies |root_transform| to the event. | 146 // Applies |root_transform| to the event. |
140 // This is applied to both |location_| and |root_location_|. | 147 // This is applied to both |location_| and |root_location_|. |
141 virtual void UpdateForRootTransform(const Transform& root_transform); | 148 virtual void UpdateForRootTransform(const Transform& root_transform); |
142 | 149 |
143 protected: | 150 protected: |
144 explicit LocatedEvent(const base::NativeEvent& native_event); | 151 explicit LocatedEvent(const base::NativeEvent& native_event); |
145 | 152 |
146 // Create a new LocatedEvent which is identical to the provided model. | 153 // Create a new LocatedEvent which is identical to the provided model. |
147 // If source / target windows are provided, the model location will be | 154 // If source / target windows are provided, the model location will be |
148 // converted from |source| coordinate system to |target| coordinate system. | 155 // converted from |source| coordinate system to |target| coordinate system. |
149 template <class T> | 156 template <class T> |
150 LocatedEvent(const LocatedEvent& model, T* source, T* target) | 157 LocatedEvent(const LocatedEvent& model, T* source, T* target) |
151 : Event(model), | 158 : Event(model), |
152 location_(model.location_), | 159 location_(model.location_), |
153 root_location_(model.root_location_) { | 160 root_location_(model.root_location_), |
161 valid_system_location_(model.valid_system_location_), | |
162 system_location_(model.system_location_) { | |
163 // TODO(erg): May need to create system_location_ by converting location to | |
164 // system coordinates here. | |
154 if (target && target != source) | 165 if (target && target != source) |
155 T::ConvertPointToTarget(source, target, &location_); | 166 T::ConvertPointToTarget(source, target, &location_); |
156 } | 167 } |
157 | 168 |
158 // Used for synthetic events in testing. | 169 // Used for synthetic events in testing. |
159 LocatedEvent(EventType type, | 170 LocatedEvent(EventType type, |
160 const gfx::Point& location, | 171 const gfx::Point& location, |
161 const gfx::Point& root_location, | 172 const gfx::Point& root_location, |
162 int flags); | 173 int flags); |
163 | 174 |
164 // Called from MouseEvent's copy ctor. | 175 // Called from MouseEvent's copy ctor. |
165 explicit LocatedEvent(const LocatedEvent& model); | 176 explicit LocatedEvent(const LocatedEvent& model); |
166 | 177 |
167 gfx::Point location_; | 178 gfx::Point location_; |
168 | 179 |
180 // |location_| multiplied by an optional transformation matrix for | |
181 // rotations, animations and skews. | |
169 gfx::Point root_location_; | 182 gfx::Point root_location_; |
183 | |
184 // |location_| in underlying system coordinates. This can be invalid during | |
Ben Goodger (Google)
2012/08/16 22:51:39
system screen coordinates.
| |
185 // |synthesized events if a location isn't explicitly set. | |
186 bool valid_system_location_; | |
187 gfx::Point system_location_; | |
170 }; | 188 }; |
171 | 189 |
172 class UI_EXPORT MouseEvent : public LocatedEvent { | 190 class UI_EXPORT MouseEvent : public LocatedEvent { |
173 public: | 191 public: |
174 explicit MouseEvent(const base::NativeEvent& native_event); | 192 explicit MouseEvent(const base::NativeEvent& native_event); |
175 | 193 |
176 // Create a new MouseEvent based on the provided model. | 194 // Create a new MouseEvent based on the provided model. |
177 // Uses the provided |type| and |flags| for the new event. | 195 // Uses the provided |type| and |flags| for the new event. |
178 // If source / target windows are provided, the model location will be | 196 // If source / target windows are provided, the model location will be |
179 // converted from |source| coordinate system to |target| coordinate system. | 197 // converted from |source| coordinate system to |target| coordinate system. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 // This value is stored as a bitfield because the number of touch ids varies, | 541 // This value is stored as a bitfield because the number of touch ids varies, |
524 // but we currently don't need more than 32 touches at a time. | 542 // but we currently don't need more than 32 touches at a time. |
525 const unsigned int touch_ids_bitfield_; | 543 const unsigned int touch_ids_bitfield_; |
526 | 544 |
527 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 545 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
528 }; | 546 }; |
529 | 547 |
530 } // namespace ui | 548 } // namespace ui |
531 | 549 |
532 #endif // UI_BASE_EVENT_H_ | 550 #endif // UI_BASE_EVENT_H_ |
OLD | NEW |