| 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_AURA_GESTURES_GESTURE_POINT_H_ | 5 #ifndef UI_AURA_GESTURES_GESTURE_POINT_H_ |
| 6 #define UI_AURA_GESTURES_GESTURE_POINT_H_ | 6 #define UI_AURA_GESTURES_GESTURE_POINT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "ui/aura/gestures/velocity_calculator.h" |
| 10 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
| 11 | 12 |
| 12 namespace aura { | 13 namespace aura { |
| 13 class TouchEvent; | 14 class TouchEvent; |
| 14 | 15 |
| 15 // Gesture state. | 16 // Gesture state. |
| 16 enum GestureState { | 17 enum GestureState { |
| 17 GS_NO_GESTURE, | 18 GS_NO_GESTURE, |
| 18 GS_PENDING_SYNTHETIC_CLICK, | 19 GS_PENDING_SYNTHETIC_CLICK, |
| 19 GS_SCROLL, | 20 GS_SCROLL, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 void UpdateForScroll(); | 38 void UpdateForScroll(); |
| 38 | 39 |
| 39 // Updates states depending on the event and the gesture-state. | 40 // Updates states depending on the event and the gesture-state. |
| 40 void UpdateValues(const TouchEvent& event, GestureState state); | 41 void UpdateValues(const TouchEvent& event, GestureState state); |
| 41 | 42 |
| 42 // Responds according to the state of the gesture point (i.e. the point can | 43 // Responds according to the state of the gesture point (i.e. the point can |
| 43 // represent a click or scroll etc.) | 44 // represent a click or scroll etc.) |
| 44 bool IsInClickWindow(const TouchEvent& event) const; | 45 bool IsInClickWindow(const TouchEvent& event) const; |
| 45 bool IsInDoubleClickWindow(const TouchEvent& event) const; | 46 bool IsInDoubleClickWindow(const TouchEvent& event) const; |
| 46 bool IsInScrollWindow(const TouchEvent& event) const; | 47 bool IsInScrollWindow(const TouchEvent& event) const; |
| 47 bool IsInFlickWindow(const TouchEvent& event) const; | 48 bool IsInFlickWindow(const TouchEvent& event); |
| 48 bool DidScroll(const TouchEvent& event) const; | 49 bool DidScroll(const TouchEvent& event) const; |
| 49 | 50 |
| 50 const gfx::Point& first_touch_position() const { | 51 const gfx::Point& first_touch_position() const { |
| 51 return first_touch_position_; | 52 return first_touch_position_; |
| 52 } | 53 } |
| 53 | 54 |
| 54 double last_touch_time() const { return last_touch_time_; } | 55 double last_touch_time() const { return last_touch_time_; } |
| 55 const gfx::Point& last_touch_position() const { return last_touch_position_; } | 56 const gfx::Point& last_touch_position() const { return last_touch_position_; } |
| 56 | 57 |
| 57 double x_delta() const { | 58 double x_delta() const { |
| 58 return last_touch_position_.x() - first_touch_position_.x(); | 59 return last_touch_position_.x() - first_touch_position_.x(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 double y_delta() const { | 62 double y_delta() const { |
| 62 return last_touch_position_.y() - first_touch_position_.y(); | 63 return last_touch_position_.y() - first_touch_position_.y(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 float x_velocity() const { return x_velocity_; } | 66 float XVelocity() { return velocity_calculator_.XVelocity(); } |
| 66 float y_velocity() const { return y_velocity_; } | 67 float YVelocity() { return velocity_calculator_.YVelocity(); } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 // Various statistical functions to manipulate gestures. | 70 // Various statistical functions to manipulate gestures. |
| 70 bool IsInClickTimeWindow() const; | 71 bool IsInClickTimeWindow() const; |
| 71 bool IsInSecondClickTimeWindow() const; | 72 bool IsInSecondClickTimeWindow() const; |
| 72 bool IsInsideManhattanSquare(const TouchEvent& event) const; | 73 bool IsInsideManhattanSquare(const TouchEvent& event) const; |
| 73 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const; | 74 bool IsSecondClickInsideManhattanSquare(const TouchEvent& event) const; |
| 74 bool IsOverMinFlickSpeed() const; | 75 bool IsOverMinFlickSpeed(); |
| 75 | 76 |
| 76 gfx::Point first_touch_position_; | 77 gfx::Point first_touch_position_; |
| 77 double first_touch_time_; | 78 double first_touch_time_; |
| 78 gfx::Point last_touch_position_; | 79 gfx::Point last_touch_position_; |
| 79 double last_touch_time_; | 80 double last_touch_time_; |
| 80 | 81 |
| 81 double last_tap_time_; | 82 double last_tap_time_; |
| 82 gfx::Point last_tap_position_; | 83 gfx::Point last_tap_position_; |
| 83 | 84 |
| 84 float x_velocity_; | 85 VelocityCalculator velocity_calculator_; |
| 85 float y_velocity_; | |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(GesturePoint); | 87 DISALLOW_COPY_AND_ASSIGN(GesturePoint); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace aura | 90 } // namespace aura |
| 91 | 91 |
| 92 #endif // UI_AURA_GESTURES_GESTURE_POINT_H_ | 92 #endif // UI_AURA_GESTURES_GESTURE_POINT_H_ |
| OLD | NEW |