base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / ui / events / gestures / fling_curve.h
blobedf0910241b30fc1d1cc7ac384817807688ab019
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_GESTURES_FLING_CURVE_H_
6 #define UI_EVENTS_GESTURES_FLING_CURVE_H_
8 #include "base/time/time.h"
9 #include "ui/events/events_base_export.h"
10 #include "ui/events/gesture_curve.h"
11 #include "ui/gfx/geometry/point_f.h"
12 #include "ui/gfx/geometry/vector2d_f.h"
14 namespace ui {
16 // FlingCurve can be used to scroll a UI element suitable for touch screen-based
17 // flings.
18 class EVENTS_BASE_EXPORT FlingCurve : public GestureCurve {
19 public:
20 FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp);
21 ~FlingCurve() override;
23 // GestureCurve implementation.
24 bool ComputeScrollOffset(base::TimeTicks time,
25 gfx::Vector2dF* offset,
26 gfx::Vector2dF* velocity) override;
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);
34 private:
35 const float curve_duration_;
36 const base::TimeTicks start_timestamp_;
38 gfx::Vector2dF displacement_ratio_;
39 gfx::Vector2dF cumulative_scroll_;
40 base::TimeTicks previous_timestamp_;
41 float time_offset_;
42 float position_offset_;
44 DISALLOW_COPY_AND_ASSIGN(FlingCurve);
47 } // namespace ui
49 #endif // UI_EVENTS_GESTURES_FLING_CURVE_H_