| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
| 10 #include "ui/events/events_base_export.h" | 10 #include "ui/events/events_base_export.h" |
| 11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 #include "ui/gfx/rect_conversions.h" | 12 #include "ui/gfx/rect_conversions.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 struct EVENTS_BASE_EXPORT GestureEventDetails { | 16 struct EVENTS_BASE_EXPORT GestureEventDetails { |
| 17 public: | 17 public: |
| 18 GestureEventDetails(); | 18 GestureEventDetails(); |
| 19 GestureEventDetails(EventType type, float delta_x, float delta_y); | 19 GestureEventDetails(EventType type, float delta_x, float delta_y); |
| 20 | 20 |
| 21 EventType type() const { return type_; } | 21 EventType type() const { return type_; } |
| 22 | 22 |
| 23 int touch_points() const { return touch_points_; } | 23 int touch_points() const { return touch_points_; } |
| 24 void set_touch_points(int touch_points) { touch_points_ = touch_points; } | 24 void set_touch_points(int touch_points) { |
| 25 DCHECK_GT(touch_points, 0); |
| 26 touch_points_ = touch_points; |
| 27 } |
| 25 | 28 |
| 26 // TODO(tdresser): Return RectF. See crbug.com/337824. | 29 // TODO(tdresser): Return RectF. See crbug.com/337824. |
| 27 const gfx::Rect bounding_box() const { | 30 const gfx::Rect bounding_box() const { |
| 28 return ToEnclosingRect(bounding_box_); | 31 return ToEnclosingRect(bounding_box_); |
| 29 } | 32 } |
| 30 | 33 |
| 31 const gfx::RectF& bounding_box_f() const { | 34 const gfx::RectF& bounding_box_f() const { |
| 32 return bounding_box_; | 35 return bounding_box_; |
| 33 } | 36 } |
| 34 | 37 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 103 } |
| 101 | 104 |
| 102 int tap_count() const { | 105 int tap_count() const { |
| 103 DCHECK(type_ == ET_GESTURE_TAP || | 106 DCHECK(type_ == ET_GESTURE_TAP || |
| 104 type_ == ET_GESTURE_TAP_UNCONFIRMED || | 107 type_ == ET_GESTURE_TAP_UNCONFIRMED || |
| 105 type_ == ET_GESTURE_DOUBLE_TAP); | 108 type_ == ET_GESTURE_DOUBLE_TAP); |
| 106 return data.tap_count; | 109 return data.tap_count; |
| 107 } | 110 } |
| 108 | 111 |
| 109 void set_tap_count(int tap_count) { | 112 void set_tap_count(int tap_count) { |
| 113 DCHECK_GE(tap_count, 0); |
| 110 DCHECK(type_ == ET_GESTURE_TAP || | 114 DCHECK(type_ == ET_GESTURE_TAP || |
| 111 type_ == ET_GESTURE_TAP_UNCONFIRMED || | 115 type_ == ET_GESTURE_TAP_UNCONFIRMED || |
| 112 type_ == ET_GESTURE_DOUBLE_TAP); | 116 type_ == ET_GESTURE_DOUBLE_TAP); |
| 113 data.tap_count = tap_count; | 117 data.tap_count = tap_count; |
| 114 } | 118 } |
| 115 | 119 |
| 116 private: | 120 private: |
| 117 EventType type_; | 121 EventType type_; |
| 118 union Details { | 122 union Details { |
| 119 Details(); | 123 Details(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 int touch_points_; // Number of active touch points in the gesture. | 162 int touch_points_; // Number of active touch points in the gesture. |
| 159 | 163 |
| 160 // Bounding box is an axis-aligned rectangle that contains all the | 164 // Bounding box is an axis-aligned rectangle that contains all the |
| 161 // enclosing rectangles of the touch-points in the gesture. | 165 // enclosing rectangles of the touch-points in the gesture. |
| 162 gfx::RectF bounding_box_; | 166 gfx::RectF bounding_box_; |
| 163 }; | 167 }; |
| 164 | 168 |
| 165 } // namespace ui | 169 } // namespace ui |
| 166 | 170 |
| 167 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ | 171 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ |
| OLD | NEW |