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

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
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 "base/callback.h"
9 #include "remoting/client/fling_tracker.h"
10
11 namespace remoting {
12
13 // This class helps interpolating the positions of an object with the given
14 // initial velocity and feeds the change in position back to the callback.
15 class FlingAnimation {
16 public:
17 using FlingCallback = base::Callback<void(float, float)>;
nicholss 2017/05/10 19:34:05 Can you document the callback please
Yuwei 2017/05/10 23:28:24 Done.
18
19 // FlingCallback: arguments are delta_x and delta_y with respect to the
20 // positions at previous tick.
nicholss 2017/05/10 19:34:05 running git cl format leaves these spaces?
Yuwei 2017/05/10 23:28:24 I was trying to follow the four-space indenting ru
21 FlingAnimation(float time_constant, const FlingCallback& fling_callback);
22 ~FlingAnimation();
23
24 // (Re)starts the fling animation with the given initial velocity.
25 void Reset(float velocity_x, float velocity_y);
nicholss 2017/05/10 19:34:05 rename to setVelocity() ?
Yuwei 2017/05/10 23:28:24 Done.
26
27 bool IsAnimationInProgress() const;
28
29 // Moves forward the animation to catch up with current time. Calls the fling
30 // callback with the new positions. No-op if fling animation is not in
31 // progress.
32 void Tick();
33
34 // Aborts the animation.
35 void Abort();
36
37 private:
38 FlingTracker fling_tracker_;
nicholss 2017/05/10 19:34:05 Forward declare rather than include?
Yuwei 2017/05/10 23:28:24 This is not a pointer nor a reference so forward d
39 FlingCallback fling_callback_;
40
41 float previous_position_x_ = 0.f;
42 float previous_position_y_ = 0.f;
43
44 // FlingAnimation is neither copyable nor movable.
45 FlingAnimation(const FlingAnimation&) = delete;
46 FlingAnimation& operator=(const FlingAnimation&) = delete;
47 };
48
49 } // namespace remoting
50 #endif // REMOTING_CLIENT_FLING_ANIMATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698