Chromium Code Reviews| Index: ui/gfx/interpolated_transform.h |
| diff --git a/ui/gfx/interpolated_transform.h b/ui/gfx/interpolated_transform.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c6cb8c1cccd9af94d7e9ea9304389c37a623f4c5 |
| --- /dev/null |
| +++ b/ui/gfx/interpolated_transform.h |
| @@ -0,0 +1,138 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_GFX_INTERPOLATED_TRANSFORM_H_ |
| +#define UI_GFX_INTERPOLATED_TRANSFORM_H_ |
| +#pragma once |
| + |
| +#include "ui/gfx/transform.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "ui/gfx/point.h" |
| + |
| +namespace ui { |
| + |
| +class InterpolatedTransform { |
|
sky
2011/06/28 15:39:14
Add a description of this class. Same comment for
|
| + public: |
| + InterpolatedTransform(); |
| + InterpolatedTransform(float start_time, float end_time); |
|
sky
2011/06/28 15:39:14
Document what start_time and end_time are.
|
| + virtual ~InterpolatedTransform() {} |
|
sky
2011/06/28 15:39:14
Don't inline this.
|
| + |
| + // Returns the interpolated transform at time t. Note: not virtual. |
| + ui::Transform Interpolate(float t) const; |
| + |
| + // Takes ownership of the other Interpolated Transform. |
| + void Compose(InterpolatedTransform* other) { child_.reset(other); } |
|
sky
2011/06/28 15:39:14
Don't inline this since it may run destructors. Al
|
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const = 0; |
|
sky
2011/06/28 15:39:14
Description.
|
| + |
| + float ValueBetween(float time, float start_value, float end_value) const; |
|
sky
2011/06/28 15:39:14
description.
|
| + |
| + private: |
| + float start_time_; |
| + float end_time_; |
| + |
| + scoped_ptr<InterpolatedTransform> child_; |
|
sky
2011/06/28 15:39:14
Description.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedTransform); |
| +}; |
| + |
| +class InterpolatedRotation : public InterpolatedTransform { |
| + public: |
| + InterpolatedRotation(float start_degrees, float end_degrees); |
| + InterpolatedRotation(float start_degrees, |
| + float end_degrees, |
| + float start_time, |
| + float end_time); |
| + virtual ~InterpolatedRotation() {} |
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const; |
| + |
| + private: |
| + float start_degrees_; |
| + float end_degrees_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedRotation); |
| +}; |
| + |
| +class InterpolatedScale : public InterpolatedTransform { |
| + public: |
| + InterpolatedScale(float start_scale, float end_scale); |
| + InterpolatedScale(float start_scale, |
| + float end_scale, |
| + float start_time, |
| + float end_time); |
| + virtual ~InterpolatedScale() {} |
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const; |
| + |
| + private: |
| + float start_scale_; |
| + float end_scale_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedScale); |
| +}; |
| + |
| +class InterpolatedTranslation : public InterpolatedTransform { |
| + public: |
| + InterpolatedTranslation(const gfx::Point& start_pos, |
| + const gfx::Point& end_pos); |
| + InterpolatedTranslation(const gfx::Point& start_pos, |
| + const gfx::Point& end_pos, |
| + float start_time, |
| + float end_time); |
| + virtual ~InterpolatedTranslation() {} |
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const; |
| + |
| + private: |
| + gfx::Point start_pos_; |
| + gfx::Point end_pos_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedTranslation); |
| +}; |
| + |
| +// This class is only useful when composed with other transforms, |
| +// see InterpolatedTransformAboutPivot |
| +class InterpolatedConstantTransform : public InterpolatedTransform { |
| + public: |
| + InterpolatedConstantTransform(const ui::Transform& transform); |
| + virtual ~InterpolatedConstantTransform() {} |
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const; |
| + |
| + private: |
| + ui::Transform transform_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform); |
| +}; |
| + |
| +class InterpolatedTransformAboutPivot : public InterpolatedTransform { |
| + public: |
| + InterpolatedTransformAboutPivot(const gfx::Point& pivot, |
| + InterpolatedTransform* transform); |
|
sky
2011/06/28 15:39:14
Document ownership of transform (and for next meth
|
| + InterpolatedTransformAboutPivot(const gfx::Point& pivot, |
| + InterpolatedTransform* transform, |
| + float start_time, |
| + float end_time); |
| + virtual ~InterpolatedTransformAboutPivot() {} |
| + |
| + protected: |
| + virtual ui::Transform InterpolateButDoNotCompose(float t) const; |
| + |
| + private: |
| + void Init(const gfx::Point& pivot, InterpolatedTransform* transform); |
| + |
| + scoped_ptr<InterpolatedTransform> transform_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformAboutPivot); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_GFX_INTERPOLATED_TRANSFORM_H_ |