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