Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/events/gestures/fling_curve.h

Issue 634373003: Consolidate content fling implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GN build Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gfx/geometry/point_f.h" 11 #include "ui/gfx/geometry/point_f.h"
11 #include "ui/gfx/geometry/vector2d_f.h" 12 #include "ui/gfx/geometry/vector2d_f.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 // 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
16 // flings. 17 // flings.
17 class EVENTS_BASE_EXPORT FlingCurve { 18 class EVENTS_BASE_EXPORT FlingCurve : public GestureCurve {
18 public: 19 public:
19 FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp); 20 FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp);
20 ~FlingCurve(); 21 virtual ~FlingCurve();
21 22
22 gfx::Vector2dF GetScrollAmountAtTime(base::TimeTicks current_timestamp); 23 // GestureCurve implementation.
23 base::TimeTicks start_timestamp() const { return start_timestamp_; } 24 virtual bool ComputeScrollOffset(base::TimeTicks time,
25 gfx::Vector2dF* offset,
26 gfx::Vector2dF* velocity) override;
27
28 // In contrast to |ComputeScrollOffset()|, this method is stateful and
29 // returns the *change* in scroll offset between successive calls.
30 // Returns true as long as the curve is still active and requires additional
31 // animation ticks.
32 bool ComputeScrollDeltaAtTime(base::TimeTicks current, gfx::Vector2dF* delta);
24 33
25 private: 34 private:
26 const float curve_duration_; 35 const float curve_duration_;
27 const base::TimeTicks start_timestamp_; 36 const base::TimeTicks start_timestamp_;
28 37
29 gfx::Vector2dF displacement_ratio_; 38 gfx::Vector2dF displacement_ratio_;
30 gfx::Vector2dF cumulative_scroll_; 39 gfx::Vector2dF cumulative_scroll_;
31 base::TimeTicks last_timestamp_; 40 base::TimeTicks previous_timestamp_;
32 float time_offset_; 41 float time_offset_;
33 float position_offset_; 42 float position_offset_;
34 43
35 DISALLOW_COPY_AND_ASSIGN(FlingCurve); 44 DISALLOW_COPY_AND_ASSIGN(FlingCurve);
36 }; 45 };
37 46
38 } // namespace ui 47 } // namespace ui
39 48
40 #endif // UI_EVENTS_GESTURES_FLING_CURVE_H_ 49 #endif // UI_EVENTS_GESTURES_FLING_CURVE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698