tween.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
1// Copyright (c) 2012 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_ANIMATION_TWEEN_H_ 6#define UI_GFX_ANIMATION_TWEEN_H_ 7 8#include "base/basictypes.h" 9#include "ui/gfx/gfx_export.h" 10#include "ui/gfx/rect.h" 11#include "ui/gfx/transform.h" 12 13namespace gfx { 14 15class GFX_EXPORT Tween { 16 public: 17 enum Type { 18 LINEAR, // Linear. 19 EASE_OUT, // Fast in, slow out (default). 20 EASE_IN, // Slow in, fast out. 21 EASE_IN_2, // Variant of EASE_IN that starts out slower. 22 EASE_IN_OUT, // Slow in and out, fast in the middle. 23 FAST_IN_OUT, // Fast in and out, slow in the middle. 24 EASE_OUT_SNAP, // Fast in, slow out, snap to final value. 25 SMOOTH_IN_OUT, // Smooth, consistent speeds in and out (sine wave). 26 ZERO, // Returns a value of 0 always. 27 }; 28 29 // Returns the value based on the tween type. |state| is from 0-1. 30 static double CalculateValue(Type type, double state); 31 32 // Conveniences for getting a value between a start and end point. 33 static double DoubleValueBetween(double value, double start, double target); 34 static float FloatValueBetween(double value, float start, float target); 35 static int IntValueBetween(double value, int start, int target); 36 static gfx::Rect RectValueBetween(double value, 37 const gfx::Rect& start_bounds, 38 const gfx::Rect& target_bounds); 39 static gfx::Transform TransformValueBetween( 40 double value, 41 const gfx::Transform& start_transform, 42 const gfx::Transform& target_transform); 43 44 private: 45 Tween(); 46 ~Tween(); 47 48 DISALLOW_COPY_AND_ASSIGN(Tween); 49}; 50 51} // namespace gfx 52 53#endif // UI_GFX_ANIMATION_TWEEN_H_ 54