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

Side by Side Diff: remoting/client/fling_tracker.h

Issue 2869723007: [CRD iOS] Viewport fling animation (Closed)
Patch Set: Merge branch 'master' into feat-fling-animation Created 3 years, 7 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
(Empty)
1 // Copyright 2017 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 REMOTING_CLIENT_FLING_TRACKER_H_
6 #define REMOTING_CLIENT_FLING_TRACKER_H_
7
8 #include "base/time/time.h"
9
10 namespace remoting {
11
12 // A class for tracking the positions of an object moving through a viscous
13 // liquid.
14 class FlingTracker {
15 public:
16 // time_constant: The larger the number the longer it takes to fling.
17 FlingTracker(float time_constant);
18
19 ~FlingTracker();
20
21 // Sets the position of the object and start fling. This will reset the
22 // existing fling.
23 void StartFling(float velocity_x, float velocity_y);
24
25 void StopFling();
26
27 bool IsFlingInProgress() const;
28
29 // Moves forward the object and catch up with |time|. The new positions will
30 // be writen to |x| and |y|.
31 // Returns true if the fling is still in progress at |time|, false otherwise,
32 // in which case |x| and |y| will not be touched.
33 bool TrackPositions(base::TimeTicks time, float* x, float* y);
nicholss 2017/05/10 19:34:05 Might be simpler if you just return deltaX, deltaY
Yuwei 2017/05/10 23:28:24 Done. I was looking at the Android Scroller, whic
34
35 private:
36 float time_constant_;
37 float initial_speed_rate_ = 0.f;
38 float velocity_ratio_x_ = 0.f;
39 float velocity_ratio_y_ = 0.f;
40 base::TimeTicks start_time_;
41
42 // FlingTracker is neither copyable nor movable.
43 FlingTracker(const FlingTracker&) = delete;
44 FlingTracker& operator=(const FlingTracker&) = delete;
45 };
46
47 } // namespace remoting
48 #endif // REMOTING_CLIENT_FLING_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698