158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// found in the LICENSE file.
458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_AUTOFILL_LOADING_ANIMATION_H_
658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define CHROME_BROWSER_UI_AUTOFILL_LOADING_ANIMATION_H_
758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "ui/gfx/animation/linear_animation.h"
958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace autofill {
1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// An animation for a dancing ellipsis.
13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class LoadingAnimation : public gfx::LinearAnimation {
1458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) public:
15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  explicit LoadingAnimation(gfx::AnimationDelegate* delegate,
16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                            int font_height);
1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual ~LoadingAnimation();
1858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // gfx::Animation implementation.
2058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual void Step(base::TimeTicks time_now) OVERRIDE;
2158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
2258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // Returns the vertical pixel offset for the nth dot.
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  double GetCurrentValueForDot(size_t dot_i) const;
2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // Stops this animation. Use this instead of Stop() to make sure future
2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // runs don't mess up on the first cycle.
2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  void Reset();
2858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
2958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) private:
3058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // Describes a frame of the animation, a la -webkit-keyframes.
3158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  struct AnimationFrame {
3258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    double value;
3358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    double position;
3458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  };
3558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
3658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  // True if the current cycle is the first one since Reset() was last called.
3758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  bool first_cycle_;
38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // The font height of the loading text, which gives the factor by which to
40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // scale the animation.
41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  const int font_height_;
4258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)};
4358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
4458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}  // namespace autofill
4558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
4658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif  // CHROME_BROWSER_UI_AUTOFILL_LOADING_ANIMATION_H_
47