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

Unified 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 win 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/gesture_curve.h ('k') | ui/events/gestures/fling_curve.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/gestures/fling_curve.h
diff --git a/ui/events/gestures/fling_curve.h b/ui/events/gestures/fling_curve.h
index 583e172c999bb8e6660181058463fcbc4c00c490..bebf6ab7460188a496b21334b74b448b0b06357b 100644
--- a/ui/events/gestures/fling_curve.h
+++ b/ui/events/gestures/fling_curve.h
@@ -7,6 +7,7 @@
#include "base/time/time.h"
#include "ui/events/events_base_export.h"
+#include "ui/events/gesture_curve.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
@@ -14,13 +15,21 @@ namespace ui {
// FlingCurve can be used to scroll a UI element suitable for touch screen-based
// flings.
-class EVENTS_BASE_EXPORT FlingCurve {
+class EVENTS_BASE_EXPORT FlingCurve : public GestureCurve {
public:
FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp);
- ~FlingCurve();
+ virtual ~FlingCurve();
- gfx::Vector2dF GetScrollAmountAtTime(base::TimeTicks current_timestamp);
- base::TimeTicks start_timestamp() const { return start_timestamp_; }
+ // GestureCurve implementation.
+ virtual bool ComputeScrollOffset(base::TimeTicks time,
+ gfx::Vector2dF* offset,
+ gfx::Vector2dF* velocity) override;
+
+ // In contrast to |ComputeScrollOffset()|, this method is stateful and
+ // returns the *change* in scroll offset between successive calls.
+ // Returns true as long as the curve is still active and requires additional
+ // animation ticks.
+ bool ComputeScrollDeltaAtTime(base::TimeTicks current, gfx::Vector2dF* delta);
private:
const float curve_duration_;
@@ -28,7 +37,7 @@ class EVENTS_BASE_EXPORT FlingCurve {
gfx::Vector2dF displacement_ratio_;
gfx::Vector2dF cumulative_scroll_;
- base::TimeTicks last_timestamp_;
+ base::TimeTicks previous_timestamp_;
float time_offset_;
float position_offset_;
« no previous file with comments | « ui/events/gesture_curve.h ('k') | ui/events/gestures/fling_curve.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698