OLD | NEW |
---|---|
(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 #include "remoting/client/fling_animation.h" | |
6 | |
7 namespace remoting { | |
8 | |
9 FlingAnimation::FlingAnimation(float time_constant, | |
nicholss
2017/05/10 19:34:05
It seems like FlingTracker could be just a core cl
Yuwei
2017/05/10 23:28:24
TBH I'm not sure :)
I'm just slightly against putt
| |
10 const FlingCallback& fling_callback) | |
11 : fling_tracker_(time_constant), fling_callback_(fling_callback) {} | |
nicholss
2017/05/10 19:34:05
I am not sure this would compile, how is a float a
Yuwei
2017/05/10 23:28:24
This is essentially calling the FlingTracker(time_
| |
12 | |
13 FlingAnimation::~FlingAnimation() {} | |
14 | |
15 void FlingAnimation::Reset(float velocity_x, float velocity_y) { | |
16 previous_position_x_ = 0.f; | |
17 previous_position_y_ = 0.f; | |
18 fling_tracker_.StartFling(velocity_x, velocity_y); | |
19 } | |
20 | |
21 bool FlingAnimation::IsAnimationInProgress() const { | |
22 return fling_tracker_.IsFlingInProgress(); | |
23 } | |
24 | |
25 void FlingAnimation::Tick() { | |
26 float x, y; | |
27 bool in_progress = | |
28 fling_tracker_.TrackPositions(base::TimeTicks::Now(), &x, &y); | |
nicholss
2017/05/10 19:34:05
If this returned deltas you would not need to know
Yuwei
2017/05/10 23:28:24
Done.
| |
29 if (in_progress) { | |
30 fling_callback_.Run(x - previous_position_x_, y - previous_position_y_); | |
31 previous_position_x_ = x; | |
32 previous_position_y_ = y; | |
33 } | |
34 } | |
35 | |
36 void FlingAnimation::Abort() { | |
37 fling_tracker_.StopFling(); | |
38 } | |
39 | |
40 } // namespace remoting | |
OLD | NEW |