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.
4
5#ifndef UI_EVENTS_GESTURES_FLING_CURVE_H_
6#define UI_EVENTS_GESTURES_FLING_CURVE_H_
7
8#include "base/time/time.h"
9#include "ui/events/events_base_export.h"
10#include "ui/gfx/geometry/point_f.h"
11#include "ui/gfx/geometry/vector2d_f.h"
12
13namespace ui {
14
15// FlingCurve can be used to scroll a UI element suitable for touch screen-based
16// flings.
17class EVENTS_BASE_EXPORT FlingCurve {
18 public:
19  FlingCurve(const gfx::Vector2dF& velocity, base::TimeTicks start_timestamp);
20  ~FlingCurve();
21
22  gfx::Vector2dF GetScrollAmountAtTime(base::TimeTicks current_timestamp);
23  base::TimeTicks start_timestamp() const { return start_timestamp_; }
24
25 private:
26  const float curve_duration_;
27  const base::TimeTicks start_timestamp_;
28
29  gfx::Vector2dF displacement_ratio_;
30  gfx::Vector2dF cumulative_scroll_;
31  base::TimeTicks last_timestamp_;
32  float time_offset_;
33  float position_offset_;
34
35  DISALLOW_COPY_AND_ASSIGN(FlingCurve);
36};
37
38}  // namespace ui
39
40#endif  // UI_EVENTS_GESTURES_FLING_CURVE_H_
41