summaryrefslogtreecommitdiffstats
path: root/chromium/cc/animation/scrollbar_animation_controller_linear_fade.h
blob: 85cdada51562208bba11889882a207ce601e8433 (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
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2012 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 CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_LINEAR_FADE_H_
#define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_LINEAR_FADE_H_

#include "base/memory/scoped_ptr.h"
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/base/cc_export.h"

namespace cc {
class LayerImpl;

class CC_EXPORT ScrollbarAnimationControllerLinearFade
    : public ScrollbarAnimationController {
 public:
  static scoped_ptr<ScrollbarAnimationControllerLinearFade> Create(
      LayerImpl* scroll_layer,
      base::TimeDelta fadeout_delay,
      base::TimeDelta fadeout_length);

  virtual ~ScrollbarAnimationControllerLinearFade();

  // ScrollbarAnimationController overrides.
  virtual bool IsAnimating() const OVERRIDE;
  virtual base::TimeDelta DelayBeforeStart(base::TimeTicks now) const OVERRIDE;

  virtual bool Animate(base::TimeTicks now) OVERRIDE;
  virtual void DidScrollGestureBegin() OVERRIDE;
  virtual void DidScrollGestureEnd(base::TimeTicks now) OVERRIDE;
  virtual void DidMouseMoveOffScrollbar(base::TimeTicks now) OVERRIDE;
  virtual bool DidScrollUpdate(base::TimeTicks now) OVERRIDE;
  virtual bool DidMouseMoveNear(base::TimeTicks now, float distance) OVERRIDE;

 protected:
  ScrollbarAnimationControllerLinearFade(LayerImpl* scroll_layer,
                                         base::TimeDelta fadeout_delay,
                                         base::TimeDelta fadeout_length);

 private:
  float OpacityAtTime(base::TimeTicks now);
  void ApplyOpacityToScrollbars(float opacity);

  LayerImpl* scroll_layer_;

  base::TimeTicks last_awaken_time_;
  bool scroll_gesture_in_progress_;
  bool scroll_gesture_has_scrolled_;

  base::TimeDelta fadeout_delay_;
  base::TimeDelta fadeout_length_;

  DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerLinearFade);
};

}  // namespace cc

#endif  // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_LINEAR_FADE_H_