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

Side by Side Diff: remoting/client/fling_animation.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
« no previous file with comments | « remoting/client/BUILD.gn ('k') | remoting/client/fling_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ANIMATION_H_
6 #define REMOTING_CLIENT_FLING_ANIMATION_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/time/tick_clock.h"
12 #include "remoting/client/fling_tracker.h"
13
14 namespace remoting {
15
16 // This class helps interpolating the positions of an object with the given
17 // initial velocity and feeds the change in position back to the callback.
18 class FlingAnimation {
19 public:
20 // arguments are delta_x and delta_y with respect to the positions at previous
21 // tick.
22 using FlingCallback = base::Callback<void(float, float)>;
23
24 FlingAnimation(float time_constant, const FlingCallback& fling_callback);
25 ~FlingAnimation();
26
27 // (Re)starts the fling animation with the given initial velocity.
28 void SetVelocity(float velocity_x, float velocity_y);
29
30 bool IsAnimationInProgress() const;
31
32 // Moves forward the animation to catch up with current time. Calls the fling
33 // callback with the new positions. No-op if fling animation is not in
34 // progress.
35 void Tick();
36
37 // Aborts the animation.
38 void Abort();
39
40 void SetTickClockForTest(std::unique_ptr<base::TickClock> clock);
41
42 private:
43 FlingTracker fling_tracker_;
44 FlingCallback fling_callback_;
45
46 base::TimeTicks fling_start_time_;
47
48 std::unique_ptr<base::TickClock> clock_;
49
50 // FlingAnimation is neither copyable nor movable.
51 FlingAnimation(const FlingAnimation&) = delete;
52 FlingAnimation& operator=(const FlingAnimation&) = delete;
53 };
54
55 } // namespace remoting
56 #endif // REMOTING_CLIENT_FLING_ANIMATION_H_
OLDNEW
« no previous file with comments | « remoting/client/BUILD.gn ('k') | remoting/client/fling_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698