| 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_GESTURES_FLING_CURVE_H_ | 5 #ifndef UI_EVENTS_GESTURES_FLING_CURVE_H_ |
| 6 #define UI_EVENTS_GESTURES_FLING_CURVE_H_ | 6 #define UI_EVENTS_GESTURES_FLING_CURVE_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "ui/events/events_base_export.h" | 9 #include "ui/events/events_base_export.h" |
| 10 #include "ui/events/gesture_curve.h" | 10 #include "ui/events/gesture_curve.h" |
| 11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
| 12 #include "ui/gfx/geometry/vector2d_f.h" | 12 #include "ui/gfx/geometry/vector2d_f.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 // FlingCurve can be used to scroll a UI element suitable for touch screen-based | 16 // FlingCurve can be used to scroll a UI element suitable for touch screen-based |
| 17 // flings. | 17 // flings. |
| 18 class EVENTS_BASE_EXPORT FlingCurve : public GestureCurve { | 18 class EVENTS_BASE_EXPORT FlingCurve : public GestureCurve { |
| 19 public: | 19 public: |
| 20 FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp); | 20 FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp); |
| 21 virtual ~FlingCurve(); | 21 ~FlingCurve() override; |
| 22 | 22 |
| 23 // GestureCurve implementation. | 23 // GestureCurve implementation. |
| 24 virtual bool ComputeScrollOffset(base::TimeTicks time, | 24 bool ComputeScrollOffset(base::TimeTicks time, |
| 25 gfx::Vector2dF* offset, | 25 gfx::Vector2dF* offset, |
| 26 gfx::Vector2dF* velocity) override; | 26 gfx::Vector2dF* velocity) override; |
| 27 | 27 |
| 28 // In contrast to |ComputeScrollOffset()|, this method is stateful and | 28 // In contrast to |ComputeScrollOffset()|, this method is stateful and |
| 29 // returns the *change* in scroll offset between successive calls. | 29 // returns the *change* in scroll offset between successive calls. |
| 30 // Returns true as long as the curve is still active and requires additional | 30 // Returns true as long as the curve is still active and requires additional |
| 31 // animation ticks. | 31 // animation ticks. |
| 32 bool ComputeScrollDeltaAtTime(base::TimeTicks current, gfx::Vector2dF* delta); | 32 bool ComputeScrollDeltaAtTime(base::TimeTicks current, gfx::Vector2dF* delta); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 const float curve_duration_; | 35 const float curve_duration_; |
| 36 const base::TimeTicks start_timestamp_; | 36 const base::TimeTicks start_timestamp_; |
| 37 | 37 |
| 38 gfx::Vector2dF displacement_ratio_; | 38 gfx::Vector2dF displacement_ratio_; |
| 39 gfx::Vector2dF cumulative_scroll_; | 39 gfx::Vector2dF cumulative_scroll_; |
| 40 base::TimeTicks previous_timestamp_; | 40 base::TimeTicks previous_timestamp_; |
| 41 float time_offset_; | 41 float time_offset_; |
| 42 float position_offset_; | 42 float position_offset_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(FlingCurve); | 44 DISALLOW_COPY_AND_ASSIGN(FlingCurve); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace ui | 47 } // namespace ui |
| 48 | 48 |
| 49 #endif // UI_EVENTS_GESTURES_FLING_CURVE_H_ | 49 #endif // UI_EVENTS_GESTURES_FLING_CURVE_H_ |
| OLD | NEW |