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

Side by Side Diff: ui/gfx/interpolated_transform.h

Issue 7328011: Introduce ui.dll / libui.so for the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | « ui/gfx/insets.h ('k') | ui/gfx/native_theme.h » ('j') | ui/ui.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 UI_GFX_INTERPOLATED_TRANSFORM_H_ 5 #ifndef UI_GFX_INTERPOLATED_TRANSFORM_H_
6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_ 6 #define UI_GFX_INTERPOLATED_TRANSFORM_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
12 #include "ui/gfx/transform.h" 12 #include "ui/gfx/transform.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 /////////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////////
17 // class InterpolatedTransform 17 // class InterpolatedTransform
18 // 18 //
19 // Abstract base class for transforms that animate over time. These 19 // Abstract base class for transforms that animate over time. These
20 // interpolated transforms can be combined to allow for more sophisticated 20 // interpolated transforms can be combined to allow for more sophisticated
21 // animations. For example, you might combine a rotation of 90 degrees between 21 // animations. For example, you might combine a rotation of 90 degrees between
22 // times 0 and 1, with a scale from 1 to 0.3 between times 0 and 0.25 and a 22 // times 0 and 1, with a scale from 1 to 0.3 between times 0 and 0.25 and a
23 // scale from 0.3 to 1 from between times 0.75 and 1. 23 // scale from 0.3 to 1 from between times 0.75 and 1.
24 // 24 //
25 /////////////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////////////
26 class InterpolatedTransform { 26 class UI_API InterpolatedTransform {
27 public: 27 public:
28 InterpolatedTransform(); 28 InterpolatedTransform();
29 // The interpolated transform varies only when t in (start_time, end_time). 29 // The interpolated transform varies only when t in (start_time, end_time).
30 // If t <= start_time, Interpolate(t) will return the initial transform, and 30 // If t <= start_time, Interpolate(t) will return the initial transform, and
31 // if t >= end_time, Interpolate(t) will return the final transform. 31 // if t >= end_time, Interpolate(t) will return the final transform.
32 InterpolatedTransform(float start_time, float end_time); 32 InterpolatedTransform(float start_time, float end_time);
33 virtual ~InterpolatedTransform(); 33 virtual ~InterpolatedTransform();
34 34
35 // Returns the interpolated transform at time t. Note: not virtual. 35 // Returns the interpolated transform at time t. Note: not virtual.
36 ui::Transform Interpolate(float t) const; 36 ui::Transform Interpolate(float t) const;
(...skipping 28 matching lines...) Expand all
65 65
66 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransform); 66 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransform);
67 }; 67 };
68 68
69 /////////////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////////////
70 // class InterpolatedRotation 70 // class InterpolatedRotation
71 // 71 //
72 // Represents an animated rotation. 72 // Represents an animated rotation.
73 // 73 //
74 /////////////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////////////
75 class InterpolatedRotation : public InterpolatedTransform { 75 class UI_API InterpolatedRotation : public InterpolatedTransform {
76 public: 76 public:
77 InterpolatedRotation(float start_degrees, float end_degrees); 77 InterpolatedRotation(float start_degrees, float end_degrees);
78 InterpolatedRotation(float start_degrees, 78 InterpolatedRotation(float start_degrees,
79 float end_degrees, 79 float end_degrees,
80 float start_time, 80 float start_time,
81 float end_time); 81 float end_time);
82 virtual ~InterpolatedRotation(); 82 virtual ~InterpolatedRotation();
83 83
84 protected: 84 protected:
85 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 85 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
86 86
87 private: 87 private:
88 const float start_degrees_; 88 const float start_degrees_;
89 const float end_degrees_; 89 const float end_degrees_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation); 91 DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation);
92 }; 92 };
93 93
94 /////////////////////////////////////////////////////////////////////////////// 94 ///////////////////////////////////////////////////////////////////////////////
95 // class InterpolatedScale 95 // class InterpolatedScale
96 // 96 //
97 // Represents an animated scale. 97 // Represents an animated scale.
98 // 98 //
99 /////////////////////////////////////////////////////////////////////////////// 99 ///////////////////////////////////////////////////////////////////////////////
100 class InterpolatedScale : public InterpolatedTransform { 100 class UI_API InterpolatedScale : public InterpolatedTransform {
101 public: 101 public:
102 InterpolatedScale(float start_scale, float end_scale); 102 InterpolatedScale(float start_scale, float end_scale);
103 InterpolatedScale(float start_scale, 103 InterpolatedScale(float start_scale,
104 float end_scale, 104 float end_scale,
105 float start_time, 105 float start_time,
106 float end_time); 106 float end_time);
107 virtual ~InterpolatedScale(); 107 virtual ~InterpolatedScale();
108 108
109 protected: 109 protected:
110 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 110 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
111 111
112 private: 112 private:
113 const float start_scale_; 113 const float start_scale_;
114 const float end_scale_; 114 const float end_scale_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(InterpolatedScale); 116 DISALLOW_COPY_AND_ASSIGN(InterpolatedScale);
117 }; 117 };
118 118
119 class InterpolatedTranslation : public InterpolatedTransform { 119 class UI_API InterpolatedTranslation : public InterpolatedTransform {
120 public: 120 public:
121 InterpolatedTranslation(const gfx::Point& start_pos, 121 InterpolatedTranslation(const gfx::Point& start_pos,
122 const gfx::Point& end_pos); 122 const gfx::Point& end_pos);
123 InterpolatedTranslation(const gfx::Point& start_pos, 123 InterpolatedTranslation(const gfx::Point& start_pos,
124 const gfx::Point& end_pos, 124 const gfx::Point& end_pos,
125 float start_time, 125 float start_time,
126 float end_time); 126 float end_time);
127 virtual ~InterpolatedTranslation(); 127 virtual ~InterpolatedTranslation();
128 128
129 protected: 129 protected:
130 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 130 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
131 131
132 private: 132 private:
133 const gfx::Point start_pos_; 133 const gfx::Point start_pos_;
134 const gfx::Point end_pos_; 134 const gfx::Point end_pos_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation); 136 DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation);
137 }; 137 };
138 138
139 /////////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////////
140 // class InterpolatedConstantTransform 140 // class InterpolatedConstantTransform
141 // 141 //
142 // Represents a transform that is constant over time. This is only useful when 142 // Represents a transform that is constant over time. This is only useful when
143 // composed with other interpolated transforms. 143 // composed with other interpolated transforms.
144 // 144 //
145 // See InterpolatedTransformAboutPivot for an example of its usage. 145 // See InterpolatedTransformAboutPivot for an example of its usage.
146 // 146 //
147 /////////////////////////////////////////////////////////////////////////////// 147 ///////////////////////////////////////////////////////////////////////////////
148 class InterpolatedConstantTransform : public InterpolatedTransform { 148 class UI_API InterpolatedConstantTransform : public InterpolatedTransform {
149 public: 149 public:
150 InterpolatedConstantTransform(const ui::Transform& transform); 150 InterpolatedConstantTransform(const ui::Transform& transform);
151 virtual ~InterpolatedConstantTransform(); 151 virtual ~InterpolatedConstantTransform();
152 152
153 protected: 153 protected:
154 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 154 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
155 155
156 private: 156 private:
157 const ui::Transform transform_; 157 const ui::Transform transform_;
158 158
159 DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform); 159 DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform);
160 }; 160 };
161 161
162 /////////////////////////////////////////////////////////////////////////////// 162 ///////////////////////////////////////////////////////////////////////////////
163 // class InterpolatedTransformAboutPivot 163 // class InterpolatedTransformAboutPivot
164 // 164 //
165 // Represents an animated transform with a transformed origin. Essentially, 165 // Represents an animated transform with a transformed origin. Essentially,
166 // at each time, t, the interpolated transform is created by composing 166 // at each time, t, the interpolated transform is created by composing
167 // P * T * P^-1 where P is a constant transform to the new origin. 167 // P * T * P^-1 where P is a constant transform to the new origin.
168 // 168 //
169 /////////////////////////////////////////////////////////////////////////////// 169 ///////////////////////////////////////////////////////////////////////////////
170 class InterpolatedTransformAboutPivot : public InterpolatedTransform { 170 class UI_API InterpolatedTransformAboutPivot : public InterpolatedTransform {
171 public: 171 public:
172 // Takes ownership of the passed transform. 172 // Takes ownership of the passed transform.
173 InterpolatedTransformAboutPivot(const gfx::Point& pivot, 173 InterpolatedTransformAboutPivot(const gfx::Point& pivot,
174 InterpolatedTransform* transform); 174 InterpolatedTransform* transform);
175 175
176 // Takes ownership of the passed transform. 176 // Takes ownership of the passed transform.
177 InterpolatedTransformAboutPivot(const gfx::Point& pivot, 177 InterpolatedTransformAboutPivot(const gfx::Point& pivot,
178 InterpolatedTransform* transform, 178 InterpolatedTransform* transform,
179 float start_time, 179 float start_time,
180 float end_time); 180 float end_time);
181 virtual ~InterpolatedTransformAboutPivot(); 181 virtual ~InterpolatedTransformAboutPivot();
182 182
183 protected: 183 protected:
184 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE; 184 virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
185 185
186 private: 186 private:
187 void Init(const gfx::Point& pivot, InterpolatedTransform* transform); 187 void Init(const gfx::Point& pivot, InterpolatedTransform* transform);
188 188
189 scoped_ptr<InterpolatedTransform> transform_; 189 scoped_ptr<InterpolatedTransform> transform_;
190 190
191 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); 191 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot);
192 }; 192 };
193 193
194 } // namespace ui 194 } // namespace ui
195 195
196 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ 196 #endif // UI_GFX_INTERPOLATED_TRANSFORM_H_
OLDNEW
« no previous file with comments | « ui/gfx/insets.h ('k') | ui/gfx/native_theme.h » ('j') | ui/ui.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698