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 { | |
140 return system_location_ != gfx::Point(-1, -1); | |
sky
2012/08/16 20:11:20
Can't -1 -1 be a valid location?
Elliot Glaysher
2012/08/16 20:33:48
I guess it might. Changed to out of band boolean t
| |
141 } | |
142 void set_system_location(const gfx::Point& loc) { system_location_ = loc; } | |
143 gfx::Point system_location() const { return system_location_; } | |
sky
2012/08/16 20:11:20
const gfx::Point&
| |
144 | |
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 system_location_(model.system_location_) { | |
162 // TODO(erg): May need to create system_location_ by converting location to | |
163 // system coordinates here. | |
154 if (target && target != source) | 164 if (target && target != source) |
155 T::ConvertPointToTarget(source, target, &location_); | 165 T::ConvertPointToTarget(source, target, &location_); |
156 } | 166 } |
157 | 167 |
158 // Used for synthetic events in testing. | 168 // Used for synthetic events in testing. |
159 LocatedEvent(EventType type, | 169 LocatedEvent(EventType type, |
160 const gfx::Point& location, | 170 const gfx::Point& location, |
161 const gfx::Point& root_location, | 171 const gfx::Point& root_location, |
162 int flags); | 172 int flags); |
163 | 173 |
164 // Called from MouseEvent's copy ctor. | 174 // Called from MouseEvent's copy ctor. |
165 explicit LocatedEvent(const LocatedEvent& model); | 175 explicit LocatedEvent(const LocatedEvent& model); |
166 | 176 |
167 gfx::Point location_; | 177 gfx::Point location_; |
168 | 178 |
179 // |location_| multiplied by an optional transformation matrix for | |
180 // rotations, animations and skews. | |
169 gfx::Point root_location_; | 181 gfx::Point root_location_; |
182 | |
183 // |location_| in underlying system coordinates. Defaults to the invalid | |
184 // value of (-1, -1), unless we're given a native event or are explicitly | |
185 // set. | |
186 gfx::Point system_location_; | |
170 }; | 187 }; |
171 | 188 |
172 class UI_EXPORT MouseEvent : public LocatedEvent { | 189 class UI_EXPORT MouseEvent : public LocatedEvent { |
173 public: | 190 public: |
174 explicit MouseEvent(const base::NativeEvent& native_event); | 191 explicit MouseEvent(const base::NativeEvent& native_event); |
175 | 192 |
176 // Create a new MouseEvent based on the provided model. | 193 // Create a new MouseEvent based on the provided model. |
177 // Uses the provided |type| and |flags| for the new event. | 194 // Uses the provided |type| and |flags| for the new event. |
178 // If source / target windows are provided, the model location will be | 195 // If source / target windows are provided, the model location will be |
179 // converted from |source| coordinate system to |target| coordinate system. | 196 // 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, | 540 // 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. | 541 // but we currently don't need more than 32 touches at a time. |
525 const unsigned int touch_ids_bitfield_; | 542 const unsigned int touch_ids_bitfield_; |
526 | 543 |
527 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 544 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
528 }; | 545 }; |
529 | 546 |
530 } // namespace ui | 547 } // namespace ui |
531 | 548 |
532 #endif // UI_BASE_EVENT_H_ | 549 #endif // UI_BASE_EVENT_H_ |
OLD | NEW |