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

Side by Side Diff: ui/gfx/animation/slide_animation.cc

Issue 2329633003: Implement progress bar spec (determinate and indeterminate). (Closed)
Patch Set: sky review Created 4 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/gfx/animation/slide_animation.h" 5 #include "ui/gfx/animation/slide_animation.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 namespace gfx { 9 namespace gfx {
10 10
11 // How many frames per second to target.
12 static const int kDefaultFrameRateHz = 60;
13
14 // How long animations should take by default. 11 // How long animations should take by default.
15 static const int kDefaultDurationMs = 120; 12 static const int kDefaultDurationMs = 120;
16 13
17 SlideAnimation::SlideAnimation(AnimationDelegate* target) 14 SlideAnimation::SlideAnimation(AnimationDelegate* target)
18 : LinearAnimation(kDefaultFrameRateHz, target), 15 : LinearAnimation(target),
19 target_(target), 16 target_(target),
20 tween_type_(Tween::EASE_OUT), 17 tween_type_(Tween::EASE_OUT),
21 showing_(false), 18 showing_(false),
22 value_start_(0), 19 value_start_(0),
23 value_end_(0), 20 value_end_(0),
24 value_current_(0), 21 value_current_(0),
25 slide_duration_(kDefaultDurationMs) { 22 slide_duration_(kDefaultDurationMs) {}
26 }
27 23
28 SlideAnimation::~SlideAnimation() { 24 SlideAnimation::~SlideAnimation() {
29 } 25 }
30 26
31 void SlideAnimation::Reset() { 27 void SlideAnimation::Reset() {
32 Reset(0); 28 Reset(0);
33 } 29 }
34 30
35 void SlideAnimation::Reset(double value) { 31 void SlideAnimation::Reset(double value) {
36 Stop(); 32 Stop();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 101
106 // Correct for any overshoot (while state may be capped at 1.0, let's not 102 // Correct for any overshoot (while state may be capped at 1.0, let's not
107 // take any rounding error chances. 103 // take any rounding error chances.
108 if ((value_end_ >= value_start_ && value_current_ > value_end_) || 104 if ((value_end_ >= value_start_ && value_current_ > value_end_) ||
109 (value_end_ < value_start_ && value_current_ < value_end_)) { 105 (value_end_ < value_start_ && value_current_ < value_end_)) {
110 value_current_ = value_end_; 106 value_current_ = value_end_;
111 } 107 }
112 } 108 }
113 109
114 } // namespace gfx 110 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698