summaryrefslogtreecommitdiffstats
path: root/ui/base/animation/tween.h
blob: 873281fd49be750206242ec2b8c206c7858a5ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 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_BASE_ANIMATION_TWEEN_H_
#define UI_BASE_ANIMATION_TWEEN_H_
#pragma once

#include "base/basictypes.h"

namespace gfx {
class Rect;
}

namespace ui {

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);
};

}  // namespace ui

#endif  // UI_BASE_ANIMATION_TWEEN_H_