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

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

Issue 2888423003: [CRD iOS] Fix bugs in FlingTracker (Closed)
Patch Set: WIP 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
« no previous file with comments | « no previous file | remoting/client/ui/fling_tracker.cc » ('j') | remoting/client/ui/fling_tracker.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 REMOTING_CLIENT_UI_FLING_TRACKER_H_ 5 #ifndef REMOTING_CLIENT_UI_FLING_TRACKER_H_
6 #define REMOTING_CLIENT_UI_FLING_TRACKER_H_ 6 #define REMOTING_CLIENT_UI_FLING_TRACKER_H_
7 7
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 9
10 namespace remoting { 10 namespace remoting {
11 11
12 // A class for tracking the positions of an object moving through a viscous 12 // A class for tracking the positions of an object moving through a viscous
13 // liquid. 13 // liquid.
14 class FlingTracker { 14 class FlingTracker {
15 public: 15 public:
16 // time_constant: The larger the number the longer it takes to fling. 16 // time_constant: The larger the number the longer it takes to fling and the
17 // further the object can move.
nicholss 2017/05/22 20:16:59 I think the extra whitespace is not needed in chro
Yuwei 2017/05/22 21:18:25 Done. Just tried to align a little bit..
17 explicit FlingTracker(float time_constant); 18 explicit FlingTracker(float time_constant);
18 19
19 ~FlingTracker(); 20 ~FlingTracker();
20 21
21 // Sets the position of the object and start fling. This will reset the 22 // Sets the position of the object and start fling. This will reset the
22 // existing fling. 23 // existing fling.
24 // velocity is in pixel per second
nicholss 2017/05/22 20:16:59 This should be a whole sentence.
Yuwei 2017/05/22 21:18:25 Done.
23 void StartFling(float velocity_x, float velocity_y); 25 void StartFling(float velocity_x, float velocity_y);
24 26
25 void StopFling(); 27 void StopFling();
26 28
27 bool IsFlingInProgress() const; 29 bool IsFlingInProgress() const;
28 30
29 // time_elapsed: The time elapsed since the animation has started. 31 // time_elapsed: The time elapsed since the animation has started.
30 // Moves forward the object to catch up with |time_elapsed|. The change in 32 // Moves forward the object to catch up with |time_elapsed|. The change in
31 // positions will be written to |dx| and |dy|. 33 // positions will be written to |dx| and |dy|.
32 // Returns true if the fling is still in progress at |time_elapsed|, false 34 // Returns true if the fling is still in progress at |time_elapsed|, false
33 // otherwise, in which case |dx| and |dy| will not be touched. 35 // otherwise, in which case |dx| and |dy| will not be touched.
34 bool TrackMovement(base::TimeDelta time_elapsed, float* dx, float* dy); 36 bool TrackMovement(base::TimeDelta time_elapsed, float* dx, float* dy);
35 37
36 private: 38 private:
37 float time_constant_; 39 float time_constant_;
38 float initial_speed_rate_ = 0.f; 40 float initial_speed_rate_ = 0.f;
41 float fling_duration_ = 0.f;
39 float velocity_ratio_x_ = 0.f; 42 float velocity_ratio_x_ = 0.f;
40 float velocity_ratio_y_ = 0.f; 43 float velocity_ratio_y_ = 0.f;
41 float previous_position_x_ = 0.f; 44 float previous_position_x_ = 0.f;
42 float previous_position_y_ = 0.f; 45 float previous_position_y_ = 0.f;
43 46
44 base::TimeTicks start_time_;
45
46 // FlingTracker is neither copyable nor movable. 47 // FlingTracker is neither copyable nor movable.
47 FlingTracker(const FlingTracker&) = delete; 48 FlingTracker(const FlingTracker&) = delete;
48 FlingTracker& operator=(const FlingTracker&) = delete; 49 FlingTracker& operator=(const FlingTracker&) = delete;
49 }; 50 };
50 51
51 } // namespace remoting 52 } // namespace remoting
52 #endif // REMOTING_CLIENT_UI_FLING_TRACKER_H_ 53 #endif // REMOTING_CLIENT_UI_FLING_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/client/ui/fling_tracker.cc » ('j') | remoting/client/ui/fling_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698