| 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_GESTURES_GESTURE_POINT_H_ | 5 #ifndef UI_BASE_GESTURES_GESTURE_POINT_H_ |
| 6 #define UI_BASE_GESTURES_GESTURE_POINT_H_ | 6 #define UI_BASE_GESTURES_GESTURE_POINT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "ui/base/gestures/velocity_calculator.h" | 9 #include "ui/base/gestures/velocity_calculator.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // A negative point_id indicates that the GesturePoint is not currently | 65 // A negative point_id indicates that the GesturePoint is not currently |
| 66 // associated with a touch. | 66 // associated with a touch. |
| 67 void set_point_id(int point_id) { point_id_ = point_id; } | 67 void set_point_id(int point_id) { point_id_ = point_id; } |
| 68 int point_id() const { return point_id_; } | 68 int point_id() const { return point_id_; } |
| 69 | 69 |
| 70 void set_touch_id(int touch_id) { touch_id_ = touch_id; } | 70 void set_touch_id(int touch_id) { touch_id_ = touch_id; } |
| 71 int touch_id() const { return touch_id_; } | 71 int touch_id() const { return touch_id_; } |
| 72 | 72 |
| 73 bool in_use() const { return point_id_ >= 0; } | 73 bool in_use() const { return point_id_ >= 0; } |
| 74 | 74 |
| 75 double x_delta() const { | 75 gfx::Vector2d ScrollDelta(); |
| 76 return last_touch_position_.x() - first_touch_position_.x(); | |
| 77 } | |
| 78 | |
| 79 double y_delta() const { | |
| 80 return last_touch_position_.y() - first_touch_position_.y(); | |
| 81 } | |
| 82 | 76 |
| 83 float XVelocity() { return velocity_calculator_.XVelocity(); } | 77 float XVelocity() { return velocity_calculator_.XVelocity(); } |
| 84 float YVelocity() { return velocity_calculator_.YVelocity(); } | 78 float YVelocity() { return velocity_calculator_.YVelocity(); } |
| 85 | 79 |
| 86 const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; } | 80 const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; } |
| 87 | 81 |
| 88 private: | 82 private: |
| 89 // Various statistical functions to manipulate gestures. | 83 // Various statistical functions to manipulate gestures. |
| 90 bool IsInClickTimeWindow() const; | 84 bool IsInClickTimeWindow() const; |
| 91 bool IsInSecondClickTimeWindow() const; | 85 bool IsInSecondClickTimeWindow() const; |
| 92 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const; | 86 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const; |
| 93 bool IsOverMinFlickSpeed(); | 87 bool IsOverMinFlickSpeed(); |
| 94 | 88 |
| 95 // The enclosing rectangle represents a rectangular touch region generated | 89 // The enclosing rectangle represents a rectangular touch region generated |
| 96 // by a sequence of ET_TOUCH_PRESSED, ET_TOUCH_MOVED, and ET_TOUCH_RELEASED | 90 // by a sequence of ET_TOUCH_PRESSED, ET_TOUCH_MOVED, and ET_TOUCH_RELEASED |
| 97 // events forming a GESTURE_TAP event. The enclosing rectangle is updated | 91 // events forming a GESTURE_TAP event. The enclosing rectangle is updated |
| 98 // to be the union of the touch data from each of these events. It is | 92 // to be the union of the touch data from each of these events. It is |
| 99 // cleared on a ET_TOUCH_PRESSED event (i.e., at the beginning of a possible | 93 // cleared on a ET_TOUCH_PRESSED event (i.e., at the beginning of a possible |
| 100 // GESTURE_TAP event) or when Reset is called. | 94 // GESTURE_TAP event) or when Reset is called. |
| 101 void UpdateEnclosingRectangle(const TouchEvent& event); | 95 void UpdateEnclosingRectangle(const TouchEvent& event); |
| 102 void clear_enclosing_rectangle() { enclosing_rect_ = gfx::Rect(); } | 96 void clear_enclosing_rectangle() { enclosing_rect_ = gfx::Rect(); } |
| 103 | 97 |
| 104 // The position of touchdown event, or of the last scroll gesture event. | 98 // The position of the first touchdown event. |
| 105 // We may want to consider tracking these two things in separate variables. | |
| 106 gfx::Point first_touch_position_; | 99 gfx::Point first_touch_position_; |
| 107 double first_touch_time_; | 100 double first_touch_time_; |
| 108 | 101 |
| 102 gfx::Point second_last_touch_position_; |
| 103 double second_last_touch_time_; |
| 104 |
| 109 gfx::Point last_touch_position_; | 105 gfx::Point last_touch_position_; |
| 110 double last_touch_time_; | 106 double last_touch_time_; |
| 111 | 107 |
| 112 double last_tap_time_; | 108 double last_tap_time_; |
| 113 gfx::Point last_tap_position_; | 109 gfx::Point last_tap_position_; |
| 114 | 110 |
| 115 VelocityCalculator velocity_calculator_; | 111 VelocityCalculator velocity_calculator_; |
| 116 | 112 |
| 117 int point_id_; | 113 int point_id_; |
| 118 int touch_id_; | 114 int touch_id_; |
| 119 | 115 |
| 120 // Represents the rectangle that encloses the circles/ellipses | 116 // Represents the rectangle that encloses the circles/ellipses |
| 121 // generated by a sequence of touch events | 117 // generated by a sequence of touch events |
| 122 gfx::Rect enclosing_rect_; | 118 gfx::Rect enclosing_rect_; |
| 123 | 119 |
| 124 DISALLOW_COPY_AND_ASSIGN(GesturePoint); | 120 DISALLOW_COPY_AND_ASSIGN(GesturePoint); |
| 125 }; | 121 }; |
| 126 | 122 |
| 127 } // namespace ui | 123 } // namespace ui |
| 128 | 124 |
| 129 #endif // UI_BASE_GESTURES_GESTURE_POINT_H_ | 125 #endif // UI_BASE_GESTURES_GESTURE_POINT_H_ |
| OLD | NEW |