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" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return type_ == ET_GESTURE_SCROLL_BEGIN || | 167 return type_ == ET_GESTURE_SCROLL_BEGIN || |
168 type_ == ET_GESTURE_SCROLL_UPDATE || | 168 type_ == ET_GESTURE_SCROLL_UPDATE || |
169 type_ == ET_GESTURE_SCROLL_END; | 169 type_ == ET_GESTURE_SCROLL_END; |
170 } | 170 } |
171 | 171 |
172 bool IsFlingScrollEvent() const { | 172 bool IsFlingScrollEvent() const { |
173 return type_ == ET_SCROLL_FLING_CANCEL || | 173 return type_ == ET_SCROLL_FLING_CANCEL || |
174 type_ == ET_SCROLL_FLING_START; | 174 type_ == ET_SCROLL_FLING_START; |
175 } | 175 } |
176 | 176 |
| 177 bool IsMouseWheelEvent() const { |
| 178 return type_ == ET_MOUSEWHEEL; |
| 179 } |
| 180 |
177 // Returns true if the event has a valid |native_event_|. | 181 // Returns true if the event has a valid |native_event_|. |
178 bool HasNativeEvent() const; | 182 bool HasNativeEvent() const; |
179 | 183 |
180 // Immediately stops the propagation of the event. This must be called only | 184 // Immediately stops the propagation of the event. This must be called only |
181 // from an EventHandler during an event-dispatch. Any event handler that may | 185 // from an EventHandler during an event-dispatch. Any event handler that may |
182 // be in the list will not receive the event after this is called. | 186 // be in the list will not receive the event after this is called. |
183 // Note that StopPropagation() can be called only for cancelable events. | 187 // Note that StopPropagation() can be called only for cancelable events. |
184 void StopPropagation(); | 188 void StopPropagation(); |
185 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } | 189 bool stopped_propagation() const { return !!(result_ & ER_CONSUMED); } |
186 | 190 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // that was released. | 393 // that was released. |
390 // NOTE: during a press and release flags() contains the complete set of | 394 // NOTE: during a press and release flags() contains the complete set of |
391 // flags. Use this to determine the button that was pressed or released. | 395 // flags. Use this to determine the button that was pressed or released. |
392 int changed_button_flags() const { return changed_button_flags_; } | 396 int changed_button_flags() const { return changed_button_flags_; } |
393 | 397 |
394 private: | 398 private: |
395 // Returns the repeat count based on the previous mouse click, if it is | 399 // Returns the repeat count based on the previous mouse click, if it is |
396 // recent enough and within a small enough distance. | 400 // recent enough and within a small enough distance. |
397 static int GetRepeatCount(const MouseEvent& click_event); | 401 static int GetRepeatCount(const MouseEvent& click_event); |
398 | 402 |
399 gfx::Point root_location_; | |
400 | |
401 // See description above getter for details. | 403 // See description above getter for details. |
402 int changed_button_flags_; | 404 int changed_button_flags_; |
403 | 405 |
404 static MouseEvent* last_click_event_; | 406 static MouseEvent* last_click_event_; |
405 }; | 407 }; |
406 | 408 |
407 class ScrollEvent; | 409 class ScrollEvent; |
408 | 410 |
409 class UI_EXPORT MouseWheelEvent : public MouseEvent { | 411 class UI_EXPORT MouseWheelEvent : public MouseEvent { |
410 public: | 412 public: |
411 // See |offset| for details. | 413 // See |offset| for details. |
412 static const int kWheelDelta; | 414 static const int kWheelDelta; |
413 | 415 |
414 explicit MouseWheelEvent(const base::NativeEvent& native_event); | 416 explicit MouseWheelEvent(const base::NativeEvent& native_event); |
415 explicit MouseWheelEvent(const ScrollEvent& scroll_event); | 417 explicit MouseWheelEvent(const ScrollEvent& scroll_event); |
416 MouseWheelEvent(const MouseEvent& mouse_event, int x_offset, int y_offset); | 418 MouseWheelEvent(const MouseEvent& mouse_event, int x_offset, int y_offset); |
| 419 MouseWheelEvent(const MouseWheelEvent& mouse_wheel_event); |
417 | 420 |
418 template <class T> | 421 template <class T> |
419 MouseWheelEvent(const MouseWheelEvent& model, | 422 MouseWheelEvent(const MouseWheelEvent& model, |
420 T* source, | 423 T* source, |
421 T* target, | 424 T* target, |
422 EventType type, | 425 EventType type, |
423 int flags) | 426 int flags) |
424 : MouseEvent(model, source, target, type, flags), | 427 : MouseEvent(model, source, target, type, flags), |
425 offset_(model.x_offset(), model.y_offset()){ | 428 offset_(model.x_offset(), model.y_offset()){ |
426 } | 429 } |
427 | 430 |
428 // The amount to scroll. This is in multiples of kWheelDelta. | 431 // The amount to scroll. This is in multiples of kWheelDelta. |
429 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. | 432 // Note: x_offset() > 0/y_offset() > 0 means scroll left/up. |
430 int x_offset() const { return offset_.x(); } | 433 int x_offset() const { return offset_.x(); } |
431 int y_offset() const { return offset_.y(); } | 434 int y_offset() const { return offset_.y(); } |
432 const gfx::Vector2d& offset() const { return offset_; } | 435 const gfx::Vector2d& offset() const { return offset_; } |
433 | 436 |
| 437 // Overridden from LocatedEvent. |
| 438 virtual void UpdateForRootTransform( |
| 439 const gfx::Transform& inverted_root_transform) OVERRIDE; |
| 440 |
434 private: | 441 private: |
435 gfx::Vector2d offset_; | 442 gfx::Vector2d offset_; |
436 | |
437 DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent); | |
438 }; | 443 }; |
439 | 444 |
440 class UI_EXPORT TouchEvent : public LocatedEvent { | 445 class UI_EXPORT TouchEvent : public LocatedEvent { |
441 public: | 446 public: |
442 explicit TouchEvent(const base::NativeEvent& native_event); | 447 explicit TouchEvent(const base::NativeEvent& native_event); |
443 | 448 |
444 // Create a new TouchEvent which is identical to the provided model. | 449 // Create a new TouchEvent which is identical to the provided model. |
445 // If source / target windows are provided, the model location will be | 450 // If source / target windows are provided, the model location will be |
446 // converted from |source| coordinate system to |target| coordinate system. | 451 // converted from |source| coordinate system to |target| coordinate system. |
447 template <class T> | 452 template <class T> |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // This value is stored as a bitfield because the number of touch ids varies, | 708 // This value is stored as a bitfield because the number of touch ids varies, |
704 // but we currently don't need more than 32 touches at a time. | 709 // but we currently don't need more than 32 touches at a time. |
705 const unsigned int touch_ids_bitfield_; | 710 const unsigned int touch_ids_bitfield_; |
706 | 711 |
707 DISALLOW_COPY_AND_ASSIGN(GestureEvent); | 712 DISALLOW_COPY_AND_ASSIGN(GestureEvent); |
708 }; | 713 }; |
709 | 714 |
710 } // namespace ui | 715 } // namespace ui |
711 | 716 |
712 #endif // UI_BASE_EVENTS_EVENT_H_ | 717 #endif // UI_BASE_EVENTS_EVENT_H_ |
OLD | NEW |