Chromium Code Reviews| 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_EVENTS_EVENT_H_ | 5 #ifndef UI_EVENTS_EVENT_H_ |
| 6 #define UI_EVENTS_EVENT_H_ | 6 #define UI_EVENTS_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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 virtual ~CancelModeEvent(); | 237 virtual ~CancelModeEvent(); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 class EVENTS_EXPORT LocatedEvent : public Event { | 240 class EVENTS_EXPORT LocatedEvent : public Event { |
| 241 public: | 241 public: |
| 242 virtual ~LocatedEvent(); | 242 virtual ~LocatedEvent(); |
| 243 | 243 |
| 244 float x() const { return location_.x(); } | 244 float x() const { return location_.x(); } |
| 245 float y() const { return location_.y(); } | 245 float y() const { return location_.y(); } |
| 246 void set_location(const gfx::PointF& location) { location_ = location; } | 246 void set_location(const gfx::PointF& location) { location_ = location; } |
| 247 // TODO(tdresser): Always return floating point location. See | 247 gfx::PointF location() const { return location_; } |
| 248 // crbug.com/337824. | |
| 249 gfx::Point location() const { return gfx::ToFlooredPoint(location_); } | |
| 250 gfx::PointF location_f() const { return location_; } | |
| 251 void set_root_location(const gfx::PointF& root_location) { | 248 void set_root_location(const gfx::PointF& root_location) { |
| 252 root_location_ = root_location; | 249 root_location_ = root_location; |
| 253 } | 250 } |
| 254 gfx::Point root_location() const { | 251 gfx::Point root_location() const { |
|
sadrul
2014/05/02 06:47:18
We can make this PointF too?
tdresser
2014/05/02 13:46:40
Do you think it makes sense to do that in the same
| |
| 255 return gfx::ToFlooredPoint(root_location_); | 252 return gfx::ToFlooredPoint(root_location_); |
| 256 } | 253 } |
| 257 | 254 |
| 258 // Transform the locations using |inverted_root_transform|. | 255 // Transform the locations using |inverted_root_transform|. |
| 259 // This is applied to both |location_| and |root_location_|. | 256 // This is applied to both |location_| and |root_location_|. |
| 260 virtual void UpdateForRootTransform( | 257 virtual void UpdateForRootTransform( |
| 261 const gfx::Transform& inverted_root_transform); | 258 const gfx::Transform& inverted_root_transform); |
| 262 | 259 |
| 263 template <class T> void ConvertLocationToTarget(T* source, T* target) { | 260 template <class T> void ConvertLocationToTarget(T* source, T* target) { |
| 264 if (!target || target == source) | 261 if (!target || target == source) |
| 265 return; | 262 return; |
| 266 // TODO(tdresser): Rewrite ConvertPointToTarget to use PointF. See | 263 // TODO(tdresser): Rewrite ConvertPointToTarget to use PointF. See |
| 267 // crbug.com/337824. | 264 // crbug.com/337824. |
|
sadrul
2014/05/02 06:47:18
Can we remove this?
tdresser
2014/05/02 13:46:40
I don't think we can remove this yet.
In a follo
| |
| 268 gfx::Point offset = gfx::ToFlooredPoint(location_); | 265 gfx::Point offset = gfx::ToFlooredPoint(location_); |
| 269 T::ConvertPointToTarget(source, target, &offset); | 266 T::ConvertPointToTarget(source, target, &offset); |
| 270 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset; | 267 gfx::Vector2d diff = gfx::ToFlooredPoint(location_) - offset; |
| 271 location_= location_ - diff; | 268 location_= location_ - diff; |
| 272 } | 269 } |
| 273 | 270 |
| 274 protected: | 271 protected: |
| 275 friend class LocatedEventTestApi; | 272 friend class LocatedEventTestApi; |
| 276 explicit LocatedEvent(const base::NativeEvent& native_event); | 273 explicit LocatedEvent(const base::NativeEvent& native_event); |
| 277 | 274 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 // The set of indices of ones in the binary representation of | 684 // The set of indices of ones in the binary representation of |
| 688 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. | 685 // touch_ids_bitfield_ is the set of touch_ids associate with this gesture. |
| 689 // This value is stored as a bitfield because the number of touch ids varies, | 686 // This value is stored as a bitfield because the number of touch ids varies, |
| 690 // but we currently don't need more than 32 touches at a time. | 687 // but we currently don't need more than 32 touches at a time. |
| 691 const unsigned int touch_ids_bitfield_; | 688 const unsigned int touch_ids_bitfield_; |
| 692 }; | 689 }; |
| 693 | 690 |
| 694 } // namespace ui | 691 } // namespace ui |
| 695 | 692 |
| 696 #endif // UI_EVENTS_EVENT_H_ | 693 #endif // UI_EVENTS_EVENT_H_ |
| OLD | NEW |