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_INTERPOLATED_TRANSFORM_H_ | |
6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_ | |
7 #pragma once | |
8 | |
9 #include "ui/gfx/transform.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "ui/gfx/point.h" | |
12 | |
13 namespace ui { | |
14 | |
15 class InterpolatedTransform { | |
sky
2011/06/28 15:39:14
Add a description of this class. Same comment for
| |
16 public: | |
17 InterpolatedTransform(); | |
18 InterpolatedTransform(float start_time, float end_time); | |
sky
2011/06/28 15:39:14
Document what start_time and end_time are.
| |
19 virtual ~InterpolatedTransform() {} | |
sky
2011/06/28 15:39:14
Don't inline this.
| |
20 | |
21 // Returns the interpolated transform at time t. Note: not virtual. | |
22 ui::Transform Interpolate(float t) const; | |
23 | |
24 // Takes ownership of the other Interpolated Transform. | |
25 void Compose(InterpolatedTransform* other) { child_.reset(other); } | |
sky
2011/06/28 15:39:14
Don't inline this since it may run destructors. Al
| |
26 | |
27 protected: | |
28 virtual ui::Transform InterpolateButDoNotCompose(float t) const = 0; | |
sky
2011/06/28 15:39:14
Description.
| |
29 | |
30 float ValueBetween(float time, float start_value, float end_value) const; | |
sky
2011/06/28 15:39:14
description.
| |
31 | |
32 private: | |
33 float start_time_; | |
34 float end_time_; | |
35 | |
36 scoped_ptr<InterpolatedTransform> child_; | |
sky
2011/06/28 15:39:14
Description.
| |
37 | |
38 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransform); | |
39 }; | |
40 | |
41 class InterpolatedRotation : public InterpolatedTransform { | |
42 public: | |
43 InterpolatedRotation(float start_degrees, float end_degrees); | |
44 InterpolatedRotation(float start_degrees, | |
45 float end_degrees, | |
46 float start_time, | |
47 float end_time); | |
48 virtual ~InterpolatedRotation() {} | |
49 | |
50 protected: | |
51 virtual ui::Transform InterpolateButDoNotCompose(float t) const; | |
52 | |
53 private: | |
54 float start_degrees_; | |
55 float end_degrees_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation); | |
58 }; | |
59 | |
60 class InterpolatedScale : public InterpolatedTransform { | |
61 public: | |
62 InterpolatedScale(float start_scale, float end_scale); | |
63 InterpolatedScale(float start_scale, | |
64 float end_scale, | |
65 float start_time, | |
66 float end_time); | |
67 virtual ~InterpolatedScale() {} | |
68 | |
69 protected: | |
70 virtual ui::Transform InterpolateButDoNotCompose(float t) const; | |
71 | |
72 private: | |
73 float start_scale_; | |
74 float end_scale_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(InterpolatedScale); | |
77 }; | |
78 | |
79 class InterpolatedTranslation : public InterpolatedTransform { | |
80 public: | |
81 InterpolatedTranslation(const gfx::Point& start_pos, | |
82 const gfx::Point& end_pos); | |
83 InterpolatedTranslation(const gfx::Point& start_pos, | |
84 const gfx::Point& end_pos, | |
85 float start_time, | |
86 float end_time); | |
87 virtual ~InterpolatedTranslation() {} | |
88 | |
89 protected: | |
90 virtual ui::Transform InterpolateButDoNotCompose(float t) const; | |
91 | |
92 private: | |
93 gfx::Point start_pos_; | |
94 gfx::Point end_pos_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation); | |
97 }; | |
98 | |
99 // This class is only useful when composed with other transforms, | |
100 // see InterpolatedTransformAboutPivot | |
101 class InterpolatedConstantTransform : public InterpolatedTransform { | |
102 public: | |
103 InterpolatedConstantTransform(const ui::Transform& transform); | |
104 virtual ~InterpolatedConstantTransform() {} | |
105 | |
106 protected: | |
107 virtual ui::Transform InterpolateButDoNotCompose(float t) const; | |
108 | |
109 private: | |
110 ui::Transform transform_; | |
111 | |
112 DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform); | |
113 }; | |
114 | |
115 class InterpolatedTransformAboutPivot : public InterpolatedTransform { | |
116 public: | |
117 InterpolatedTransformAboutPivot(const gfx::Point& pivot, | |
118 InterpolatedTransform* transform); | |
sky
2011/06/28 15:39:14
Document ownership of transform (and for next meth
| |
119 InterpolatedTransformAboutPivot(const gfx::Point& pivot, | |
120 InterpolatedTransform* transform, | |
121 float start_time, | |
122 float end_time); | |
123 virtual ~InterpolatedTransformAboutPivot() {} | |
124 | |
125 protected: | |
126 virtual ui::Transform InterpolateButDoNotCompose(float t) const; | |
127 | |
128 private: | |
129 void Init(const gfx::Point& pivot, InterpolatedTransform* transform); | |
130 | |
131 scoped_ptr<InterpolatedTransform> transform_; | |
132 | |
133 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); | |
134 }; | |
135 | |
136 } // namespace ui | |
137 | |
138 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ | |
OLD | NEW |