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 21 matching lines...) Expand all Loading... |
32 // point. | 32 // point. |
33 void UpdateForScroll(); | 33 void UpdateForScroll(); |
34 | 34 |
35 // Updates states depending on the event and the gesture-state. | 35 // Updates states depending on the event and the gesture-state. |
36 void UpdateValues(const TouchEvent& event); | 36 void UpdateValues(const TouchEvent& event); |
37 | 37 |
38 // Responds according to the state of the gesture point (i.e. the point can | 38 // Responds according to the state of the gesture point (i.e. the point can |
39 // represent a click or scroll etc.) | 39 // represent a click or scroll etc.) |
40 bool IsInClickWindow(const TouchEvent& event) const; | 40 bool IsInClickWindow(const TouchEvent& event) const; |
41 bool IsInDoubleClickWindow(const TouchEvent& event) const; | 41 bool IsInDoubleClickWindow(const TouchEvent& event) const; |
| 42 bool IsInTripleClickWindow(const TouchEvent& event) const; |
42 bool IsInScrollWindow(const TouchEvent& event) const; | 43 bool IsInScrollWindow(const TouchEvent& event) const; |
43 bool IsInFlickWindow(const TouchEvent& event); | 44 bool IsInFlickWindow(const TouchEvent& event); |
44 bool IsInHorizontalRailWindow() const; | 45 bool IsInHorizontalRailWindow() const; |
45 bool IsInVerticalRailWindow() const; | 46 bool IsInVerticalRailWindow() const; |
46 bool IsInsideManhattanSquare(const TouchEvent& event) const; | 47 bool IsInsideManhattanSquare(const TouchEvent& event) const; |
47 bool BreaksHorizontalRail(); | 48 bool BreaksHorizontalRail(); |
48 bool BreaksVerticalRail(); | 49 bool BreaksVerticalRail(); |
49 bool DidScroll(const TouchEvent& event, int distance) const; | 50 bool DidScroll(const TouchEvent& event, int distance) const; |
50 | 51 |
51 const gfx::Point& first_touch_position() const { | 52 const gfx::Point& first_touch_position() const { |
(...skipping 26 matching lines...) Expand all Loading... |
78 | 79 |
79 const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; } | 80 const gfx::Rect& enclosing_rectangle() const { return enclosing_rect_; } |
80 | 81 |
81 // Tests if the point has a consistent scroll vector across a window of touch | 82 // Tests if the point has a consistent scroll vector across a window of touch |
82 // move events. | 83 // move events. |
83 bool IsConsistentScrollingActionUnderway(); | 84 bool IsConsistentScrollingActionUnderway(); |
84 | 85 |
85 private: | 86 private: |
86 // Various statistical functions to manipulate gestures. | 87 // Various statistical functions to manipulate gestures. |
87 bool IsInClickTimeWindow() const; | 88 bool IsInClickTimeWindow() const; |
88 bool IsInSecondClickTimeWindow() const; | 89 bool IsInClickAggregateTimeWindow(double before, double after) const; |
89 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const; | 90 bool IsPointInsideManhattanSquare(gfx::Point p1, gfx::Point p2) const; |
90 bool IsOverMinFlickSpeed(); | 91 bool IsOverMinFlickSpeed(); |
91 | 92 |
92 // Returns -1, 0, 1 for |v| below the negative velocity threshold, | 93 // Returns -1, 0, 1 for |v| below the negative velocity threshold, |
93 // in [-threshold, threshold] or above respectively. | 94 // in [-threshold, threshold] or above respectively. |
94 int ScrollVelocityDirection(float v); | 95 int ScrollVelocityDirection(float v); |
95 | 96 |
96 // The enclosing rectangle represents a rectangular touch region generated | 97 // The enclosing rectangle represents a rectangular touch region generated |
97 // by a sequence of ET_TOUCH_PRESSED, ET_TOUCH_MOVED, and ET_TOUCH_RELEASED | 98 // by a sequence of ET_TOUCH_PRESSED, ET_TOUCH_MOVED, and ET_TOUCH_RELEASED |
98 // events forming a GESTURE_TAP event. The enclosing rectangle is updated | 99 // events forming a GESTURE_TAP event. The enclosing rectangle is updated |
99 // to be the union of the touch data from each of these events. It is | 100 // to be the union of the touch data from each of these events. It is |
100 // cleared on a ET_TOUCH_PRESSED event (i.e., at the beginning of a possible | 101 // cleared on a ET_TOUCH_PRESSED event (i.e., at the beginning of a possible |
101 // GESTURE_TAP event) or when Reset is called. | 102 // GESTURE_TAP event) or when Reset is called. |
102 void UpdateEnclosingRectangle(const TouchEvent& event); | 103 void UpdateEnclosingRectangle(const TouchEvent& event); |
103 void clear_enclosing_rectangle() { enclosing_rect_ = gfx::Rect(); } | 104 void clear_enclosing_rectangle() { enclosing_rect_ = gfx::Rect(); } |
104 | 105 |
105 // The position of the first touchdown event. | 106 // The position of the first touchdown event. |
106 gfx::Point first_touch_position_; | 107 gfx::Point first_touch_position_; |
107 double first_touch_time_; | 108 double first_touch_time_; |
108 | 109 |
109 gfx::Point second_last_touch_position_; | 110 gfx::Point second_last_touch_position_; |
110 double second_last_touch_time_; | 111 double second_last_touch_time_; |
111 | 112 |
112 gfx::Point last_touch_position_; | 113 gfx::Point last_touch_position_; |
113 double last_touch_time_; | 114 double last_touch_time_; |
114 | 115 |
| 116 double second_last_tap_time_; |
| 117 gfx::Point second_last_tap_position_; |
| 118 |
115 double last_tap_time_; | 119 double last_tap_time_; |
116 gfx::Point last_tap_position_; | 120 gfx::Point last_tap_position_; |
117 | 121 |
118 VelocityCalculator velocity_calculator_; | 122 VelocityCalculator velocity_calculator_; |
119 | 123 |
120 int point_id_; | 124 int point_id_; |
121 int touch_id_; | 125 int touch_id_; |
122 | 126 |
123 // Represents the rectangle that encloses the circles/ellipses | 127 // Represents the rectangle that encloses the circles/ellipses |
124 // generated by a sequence of touch events | 128 // generated by a sequence of touch events |
125 gfx::Rect enclosing_rect_; | 129 gfx::Rect enclosing_rect_; |
126 | 130 |
127 // Count of the number of events with same direction. | 131 // Count of the number of events with same direction. |
128 gfx::Vector2d same_direction_count_; | 132 gfx::Vector2d same_direction_count_; |
129 | 133 |
130 DISALLOW_COPY_AND_ASSIGN(GesturePoint); | 134 DISALLOW_COPY_AND_ASSIGN(GesturePoint); |
131 }; | 135 }; |
132 | 136 |
133 } // namespace ui | 137 } // namespace ui |
134 | 138 |
135 #endif // UI_BASE_GESTURES_GESTURE_POINT_H_ | 139 #endif // UI_BASE_GESTURES_GESTURE_POINT_H_ |
OLD | NEW |