OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ | |
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ | |
7 #pragma once | |
8 | |
9 #include <vector> | |
10 | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/time.h" | |
13 #include "ui/gfx/compositor/layer_animation_element.h" | |
14 | |
15 namespace ui { | |
16 | |
17 class LayerAnimationDelegate; | |
18 | |
19 // Contains a collection of layer animation elements. Although it has a similar | |
sky
2011/10/14 16:39:52
Clarify this runs the elements one after another.
| |
20 // interface to LayerAnimationElement, it is not a LayerAnimationElement (i.e., | |
21 // it is not permitted to have a sequence in a sequence). | |
sky
2011/10/14 16:39:52
Also document who owns these
| |
22 // | |
23 // TODO(vollick) Create a 'blended' sequence for transitioning between | |
24 // sequences. | |
25 class LayerAnimationSequence : public base::RefCounted<LayerAnimationSequence> { | |
sky
2011/10/14 16:39:52
same comment about refcounted here.
| |
26 public: | |
27 typedef std::vector<scoped_refptr<LayerAnimationElement> > Elements; | |
28 | |
29 LayerAnimationSequence(); | |
30 LayerAnimationSequence(LayerAnimationElement* element); | |
sky
2011/10/14 16:39:52
explicit
| |
31 | |
32 // Updates the delegate to the appropriate value for |elapsed|, which is in | |
33 // the range [0, Duration()]. If the animation is not aborted, it is | |
34 // guaranteed that Animate will be called with elapsed = Duration(). | |
35 void Progress(base::TimeDelta elapsed, LayerAnimationDelegate* delegate); | |
36 | |
37 // Aborts the given animation. | |
38 void Abort(); | |
39 | |
40 // All properties modified by the sequence. | |
41 const LayerAnimationElement::AnimatableProperties& properties() const { | |
42 return properties_; | |
43 } | |
44 | |
45 // The total, finite duration of one cycle of the sequence. | |
46 base::TimeDelta duration() const { | |
47 return duration_; | |
48 } | |
49 | |
50 // Adds an element to the sequence. | |
51 void AddElement(LayerAnimationElement* element); | |
52 | |
53 // Sequences can be looped indefinitely. | |
54 void set_is_cyclic(bool is_cyclic) { is_cyclic_ = is_cyclic; } | |
55 bool is_cyclic() const { return is_cyclic_; } | |
56 | |
57 // Returns true, if the sequences share a common property | |
sky
2011/10/14 16:39:52
nit: end with '.'.
| |
58 bool HasCommonProperty(const LayerAnimationSequence& other) const; | |
59 | |
60 private: | |
61 friend class base::RefCounted<LayerAnimationSequence>; | |
62 virtual ~LayerAnimationSequence(); | |
63 | |
64 base::TimeDelta duration_; | |
65 LayerAnimationElement::AnimatableProperties properties_; | |
66 Elements elements_; | |
67 bool is_cyclic_; | |
68 | |
69 // these are used when animating to efficiently find the next element | |
70 Elements::size_type last_element_; | |
71 base::TimeDelta last_start_; | |
sky
2011/10/14 16:39:52
I think you want timeticks for this sort of stuff.
| |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(LayerAnimationSequence); | |
74 }; | |
75 | |
76 } // namespace ui | |
77 | |
78 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_SEQUENCE_H_ | |
OLD | NEW |