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_EVENTS_EVENT_H_ | 5 #ifndef UI_BASE_EVENTS_EVENT_H_ |
6 #define UI_BASE_EVENTS_EVENT_H_ | 6 #define UI_BASE_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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "ui/base/dragdrop/os_exchange_data.h" | 13 #include "ui/base/dragdrop/os_exchange_data.h" |
14 #include "ui/base/events/event_constants.h" | 14 #include "ui/base/events/event_constants.h" |
15 #include "ui/base/gestures/gesture_types.h" | 15 #include "ui/base/gestures/gesture_types.h" |
16 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
17 #include "ui/base/ui_export.h" | 17 #include "ui/base/ui_export.h" |
18 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
19 | 19 |
| 20 namespace gfx { |
| 21 class Transform; |
| 22 } |
| 23 |
20 namespace ui { | 24 namespace ui { |
21 class Transform; | |
22 class EventTarget; | 25 class EventTarget; |
23 | 26 |
24 class UI_EXPORT Event { | 27 class UI_EXPORT Event { |
25 public: | 28 public: |
26 virtual ~Event(); | 29 virtual ~Event(); |
27 | 30 |
28 class DispatcherApi { | 31 class DispatcherApi { |
29 public: | 32 public: |
30 explicit DispatcherApi(Event* event) : event_(event) {} | 33 explicit DispatcherApi(Event* event) : event_(event) {} |
31 | 34 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 216 |
214 bool valid_system_location() const { return valid_system_location_; } | 217 bool valid_system_location() const { return valid_system_location_; } |
215 void set_system_location(const gfx::Point& loc) { | 218 void set_system_location(const gfx::Point& loc) { |
216 valid_system_location_ = true; | 219 valid_system_location_ = true; |
217 system_location_ = loc; | 220 system_location_ = loc; |
218 } | 221 } |
219 const gfx::Point& system_location() const { return system_location_; } | 222 const gfx::Point& system_location() const { return system_location_; } |
220 | 223 |
221 // Applies |root_transform| to the event. | 224 // Applies |root_transform| to the event. |
222 // This is applied to both |location_| and |root_location_|. | 225 // This is applied to both |location_| and |root_location_|. |
223 virtual void UpdateForRootTransform(const Transform& root_transform); | 226 virtual void UpdateForRootTransform(const gfx::Transform& root_transform); |
224 | 227 |
225 template <class T> void ConvertLocationToTarget(T* source, T* target) { | 228 template <class T> void ConvertLocationToTarget(T* source, T* target) { |
226 if (target && target != source) | 229 if (target && target != source) |
227 T::ConvertPointToTarget(source, target, &location_); | 230 T::ConvertPointToTarget(source, target, &location_); |
228 } | 231 } |
229 | 232 |
230 protected: | 233 protected: |
231 explicit LocatedEvent(const base::NativeEvent& native_event); | 234 explicit LocatedEvent(const base::NativeEvent& native_event); |
232 | 235 |
233 // Create a new LocatedEvent which is identical to the provided model. | 236 // Create a new LocatedEvent which is identical to the provided model. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // generates the events need to be remapped to a surface of a different | 422 // generates the events need to be remapped to a surface of a different |
420 // size. |from| is the size of the native surface, and |to| is the size | 423 // size. |from| is the size of the native surface, and |to| is the size |
421 // of the target surface. | 424 // of the target surface. |
422 void CalibrateLocation(const gfx::Size& from, const gfx::Size& to); | 425 void CalibrateLocation(const gfx::Size& from, const gfx::Size& to); |
423 | 426 |
424 // Used for unit tests. | 427 // Used for unit tests. |
425 void set_radius_x(const float r) { radius_x_ = r; } | 428 void set_radius_x(const float r) { radius_x_ = r; } |
426 void set_radius_y(const float r) { radius_y_ = r; } | 429 void set_radius_y(const float r) { radius_y_ = r; } |
427 | 430 |
428 // Overridden from LocatedEvent. | 431 // Overridden from LocatedEvent. |
429 virtual void UpdateForRootTransform(const Transform& root_transform) OVERRIDE; | 432 virtual void UpdateForRootTransform( |
| 433 const gfx::Transform& root_transform) OVERRIDE; |
430 | 434 |
431 protected: | 435 protected: |
432 void set_radius(float radius_x, float radius_y) { | 436 void set_radius(float radius_x, float radius_y) { |
433 radius_x_ = radius_x; | 437 radius_x_ = radius_x; |
434 radius_y_ = radius_y; | 438 radius_y_ = radius_y; |
435 } | 439 } |
436 | 440 |
437 void set_rotation_angle(float rotation_angle) { | 441 void set_rotation_angle(float rotation_angle) { |
438 rotation_angle_ = rotation_angle; | 442 rotation_angle_ = rotation_angle; |
439 } | 443 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 // This value is stored as a bitfield because the number of touch ids varies, | 637 // This value is stored as a bitfield because the number of touch ids varies, |
634 // but we currently don't need more than 32 touches at a time. | 638 // but we currently don't need more than 32 touches at a time. |
635 const unsigned int touch_ids_bitfield_; | 639 const unsigned int touch_ids_bitfield_; |
636 | 640 |
637 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 641 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
638 }; | 642 }; |
639 | 643 |
640 } // namespace ui | 644 } // namespace ui |
641 | 645 |
642 #endif // UI_BASE_EVENTS_EVENT_H_ | 646 #endif // UI_BASE_EVENTS_EVENT_H_ |
OLD | NEW |