summaryrefslogtreecommitdiffstats
path: root/app/tween.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 03:43:55 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 03:43:55 +0000
commit4ce7e15da651c6221720e33dc8c500830d4b6b8a (patch)
tree376ef1d7e7951dae3376e65f4edee9e7367adc89 /app/tween.h
parent5ee3ca64cdf2d00f82a1bc36f36e8ab5e520b4de (diff)
downloadchromium_src-4ce7e15da651c6221720e33dc8c500830d4b6b8a.zip
chromium_src-4ce7e15da651c6221720e33dc8c500830d4b6b8a.tar.gz
chromium_src-4ce7e15da651c6221720e33dc8c500830d4b6b8a.tar.bz2
Refactors animation to allow for cleaner subclassing. I'm doing this
for creating a different animation subclass (which you'll see shortly). BUG=none TEST=none Review URL: http://codereview.chromium.org/1961001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/tween.h')
-rw-r--r--app/tween.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/tween.h b/app/tween.h
new file mode 100644
index 0000000..41785ef6
--- /dev/null
+++ b/app/tween.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2010 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 APP_TWEEN_H_
+#define APP_TWEEN_H_
+
+#include "base/logging.h"
+
+namespace gfx {
+class Rect;
+}
+
+class Tween {
+ public:
+ enum Type {
+ LINEAR, // Linear.
+ EASE_OUT, // Fast in, slow out (default).
+ EASE_IN, // Slow in, fast out.
+ EASE_IN_OUT, // Slow in and out, fast in the middle.
+ FAST_IN_OUT, // Fast in and out, slow in the middle.
+ EASE_OUT_SNAP, // Fast in, slow out, snap to final value.
+ ZERO, // Returns a value of 0 always.
+ };
+
+ // Returns the value based on the tween type. |state| is from 0-1.
+ static double CalculateValue(Type type, double state);
+
+ // Conveniences for getting a value between a start and end point.
+ static double ValueBetween(double value, double start, double target);
+ static int ValueBetween(double value, int start, int target);
+ static gfx::Rect ValueBetween(double value,
+ const gfx::Rect& start_bounds,
+ const gfx::Rect& target_bounds);
+
+ private:
+ Tween();
+ ~Tween();
+
+ DISALLOW_COPY_AND_ASSIGN(Tween);
+};
+
+#endif // APP_TWEEN_H_