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: app/multi_animation.h

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « app/linear_animation.cc ('k') | app/multi_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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 APP_MULTI_ANIMATION_H_ 5 #ifndef APP_MULTI_ANIMATION_H_
6 #define APP_MULTI_ANIMATION_H_ 6 #define APP_MULTI_ANIMATION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include "ui/base/animation/multi_animation.h"
10
11 #include "app/animation.h"
12 #include "app/tween.h"
13
14 // MultiAnimation is an animation that consists of a number of sub animations.
15 // To create a MultiAnimation pass in the parts, invoke Start() and the delegate
16 // is notified as the animation progresses. By default MultiAnimation runs until
17 // Stop is invoked, see |set_continuous()| for details.
18 class MultiAnimation : public Animation {
19 public:
20 // Defines part of the animation. Each part consists of the following:
21 //
22 // time_ms: the time of the part.
23 // start_time_ms: the amount of time to offset this part by when calculating
24 // the percented completed.
25 // end_time_ms: the end time used to calculate the percentange completed.
26 //
27 // In most cases |start_time_ms| = 0 and |end_time_ms| = |time_ms|. But you
28 // can adjust the start/end for different effects. For example, to run a part
29 // for 200ms with a % between .25 and .75 use the following three values: 200,
30 // 100, 400.
31 struct Part {
32 Part() : time_ms(0), start_time_ms(0), end_time_ms(0), type(Tween::ZERO) {}
33 Part(int time_ms, Tween::Type type)
34 : time_ms(time_ms),
35 start_time_ms(0),
36 end_time_ms(time_ms),
37 type(type) {}
38
39 int time_ms;
40 int start_time_ms;
41 int end_time_ms;
42 Tween::Type type;
43 };
44
45 typedef std::vector<Part> Parts;
46
47 explicit MultiAnimation(const Parts& parts);
48 virtual ~MultiAnimation();
49
50 // Sets whether the animation continues after it reaches the end. If true, the
51 // animation runs until explicitly stopped. The default is true.
52 void set_continuous(bool continuous) { continuous_ = continuous; }
53
54 // Returns the current value. The current value for a MultiAnimation is
55 // determined from the tween type of the current part.
56 virtual double GetCurrentValue() const;
57
58 // Returns the index of the current part.
59 size_t current_part_index() const { return current_part_index_; }
60
61 protected:
62 // Animation overrides.
63 virtual void Step(base::TimeTicks time_now);
64 virtual void SetStartTime(base::TimeTicks start_time);
65
66 private:
67 // Returns the part containing the specified time. |time_ms| is reset to be
68 // relative to the part containing the time and |part_index| the index of the
69 // part.
70 const Part& GetPart(int* time_ms, size_t* part_index);
71
72 // The parts that make up the animation.
73 const Parts parts_;
74
75 // Total time of all the parts.
76 const int cycle_time_ms_;
77
78 // Current value for the animation.
79 double current_value_;
80
81 // Index of the current part.
82 size_t current_part_index_;
83
84 // See description above setter.
85 bool continuous_;
86
87 DISALLOW_COPY_AND_ASSIGN(MultiAnimation);
88 };
89 10
90 #endif // APP_MULTI_ANIMATION_H_ 11 #endif // APP_MULTI_ANIMATION_H_
OLDNEW
« no previous file with comments | « app/linear_animation.cc ('k') | app/multi_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698