IndexedDB: fsync after transactions.
[chromium-blink-merge.git] / cc / animation / scrollbar_animation_controller_thinning.h
blob07b4515ec3136b57ac071d92fc39d6ba00e5dae3
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/animation/scrollbar_animation_controller.h"
10 #include "cc/base/cc_export.h"
12 namespace cc {
13 class LayerImpl;
15 // Scrollbar animation that partially fades and thins after an idle delay.
16 class CC_EXPORT ScrollbarAnimationControllerThinning
17 : public ScrollbarAnimationController {
18 public:
19 static scoped_ptr<ScrollbarAnimationControllerThinning> Create(
20 LayerImpl* scroll_layer);
22 static scoped_ptr<ScrollbarAnimationControllerThinning> CreateForTest(
23 LayerImpl* scroll_layer,
24 base::TimeDelta animation_delay,
25 base::TimeDelta animation_duration);
27 virtual ~ScrollbarAnimationControllerThinning();
29 void set_mouse_move_distance_for_test(float distance) {
30 mouse_move_distance_to_trigger_animation_ = distance;
32 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; }
33 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; }
35 // ScrollbarAnimationController overrides.
36 virtual bool IsAnimating() const OVERRIDE;
37 virtual base::TimeDelta DelayBeforeStart(base::TimeTicks now) const OVERRIDE;
39 virtual bool Animate(base::TimeTicks now) OVERRIDE;
40 virtual void DidScrollGestureBegin() OVERRIDE;
41 virtual void DidScrollGestureEnd(base::TimeTicks now) OVERRIDE;
42 virtual void DidMouseMoveOffScrollbar(base::TimeTicks now) OVERRIDE;
43 virtual bool DidScrollUpdate(base::TimeTicks now) OVERRIDE;
44 virtual bool DidMouseMoveNear(base::TimeTicks now, float distance) OVERRIDE;
46 protected:
47 ScrollbarAnimationControllerThinning(LayerImpl* scroll_layer,
48 base::TimeDelta animation_delay,
49 base::TimeDelta animation_duration);
51 private:
52 // Describes whether the current animation should INCREASE (darken / thicken)
53 // a bar or DECREASE it (lighten / thin).
54 enum AnimationChange {
55 NONE,
56 INCREASE,
57 DECREASE
59 // Returns how far through the animation we are as a progress value from
60 // 0 to 1.
61 float AnimationProgressAtTime(base::TimeTicks now);
62 float OpacityAtAnimationProgress(float progress);
63 float ThumbThicknessScaleAtAnimationProgress(float progress);
64 float AdjustScale(float new_value,
65 float current_value,
66 AnimationChange animation_change);
67 void ApplyOpacityAndThumbThicknessScale(float opacity,
68 float thumb_thickness_scale);
70 LayerImpl* scroll_layer_;
72 base::TimeTicks last_awaken_time_;
73 bool mouse_is_over_scrollbar_;
74 bool mouse_is_near_scrollbar_;
75 // Are we narrowing or thickening the bars.
76 AnimationChange thickness_change_;
77 // Are we darkening or lightening the bars.
78 AnimationChange opacity_change_;
79 // Should the animation be delayed or start immediately.
80 bool should_delay_animation_;
81 // If |should_delay_animation_| is true, delay the animation by this amount.
82 base::TimeDelta animation_delay_;
83 // The time for the animation to run.
84 base::TimeDelta animation_duration_;
85 // How close should the mouse be to the scrollbar before we thicken it.
86 float mouse_move_distance_to_trigger_animation_;
88 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning);
91 } // namespace cc
93 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_