OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 5 #ifndef CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 6 #define CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/animation/scrollbar_animation_controller.h" | 9 #include "cc/animation/scrollbar_animation_controller.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 class LayerImpl; | 13 class LayerImpl; |
14 | 14 |
15 // Scrollbar animation that partially fades and thins after an idle delay, | 15 // Scrollbar animation that partially fades and thins after an idle delay, |
16 // and reacts to mouse movements. | 16 // and reacts to mouse movements. |
17 class CC_EXPORT ScrollbarAnimationControllerThinning | 17 class CC_EXPORT ScrollbarAnimationControllerThinning |
18 : public ScrollbarAnimationController { | 18 : public ScrollbarAnimationController { |
19 public: | 19 public: |
20 static scoped_ptr<ScrollbarAnimationControllerThinning> Create( | 20 static scoped_ptr<ScrollbarAnimationControllerThinning> Create( |
21 LayerImpl* scroll_layer, | 21 LayerImpl* scroll_layer, |
22 ScrollbarAnimationControllerClient* client, | 22 ScrollbarAnimationControllerClient* client, |
23 base::TimeDelta delay_before_starting, | 23 base::TimeDelta delay_before_starting, |
24 base::TimeDelta resize_delay_before_starting, | 24 base::TimeDelta resize_delay_before_starting, |
25 base::TimeDelta duration); | 25 base::TimeDelta duration); |
26 | 26 |
27 virtual ~ScrollbarAnimationControllerThinning(); | 27 ~ScrollbarAnimationControllerThinning() override; |
28 | 28 |
29 void set_mouse_move_distance_for_test(float distance) { | 29 void set_mouse_move_distance_for_test(float distance) { |
30 mouse_move_distance_to_trigger_animation_ = distance; | 30 mouse_move_distance_to_trigger_animation_ = distance; |
31 } | 31 } |
32 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } | 32 bool mouse_is_over_scrollbar() const { return mouse_is_over_scrollbar_; } |
33 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } | 33 bool mouse_is_near_scrollbar() const { return mouse_is_near_scrollbar_; } |
34 | 34 |
35 virtual void DidScrollUpdate(bool on_resize) override; | 35 void DidScrollUpdate(bool on_resize) override; |
36 virtual void DidMouseMoveOffScrollbar() override; | 36 void DidMouseMoveOffScrollbar() override; |
37 virtual void DidMouseMoveNear(float distance) override; | 37 void DidMouseMoveNear(float distance) override; |
38 | 38 |
39 protected: | 39 protected: |
40 ScrollbarAnimationControllerThinning( | 40 ScrollbarAnimationControllerThinning( |
41 LayerImpl* scroll_layer, | 41 LayerImpl* scroll_layer, |
42 ScrollbarAnimationControllerClient* client, | 42 ScrollbarAnimationControllerClient* client, |
43 base::TimeDelta delay_before_starting, | 43 base::TimeDelta delay_before_starting, |
44 base::TimeDelta resize_delay_before_starting, | 44 base::TimeDelta resize_delay_before_starting, |
45 base::TimeDelta duration); | 45 base::TimeDelta duration); |
46 | 46 |
47 virtual void RunAnimationFrame(float progress) override; | 47 void RunAnimationFrame(float progress) override; |
48 | 48 |
49 private: | 49 private: |
50 // Describes whether the current animation should INCREASE (darken / thicken) | 50 // Describes whether the current animation should INCREASE (darken / thicken) |
51 // a bar or DECREASE it (lighten / thin). | 51 // a bar or DECREASE it (lighten / thin). |
52 enum AnimationChange { | 52 enum AnimationChange { |
53 NONE, | 53 NONE, |
54 INCREASE, | 54 INCREASE, |
55 DECREASE | 55 DECREASE |
56 }; | 56 }; |
57 float OpacityAtAnimationProgress(float progress); | 57 float OpacityAtAnimationProgress(float progress); |
(...skipping 14 matching lines...) Expand all Loading... |
72 AnimationChange opacity_change_; | 72 AnimationChange opacity_change_; |
73 // How close should the mouse be to the scrollbar before we thicken it. | 73 // How close should the mouse be to the scrollbar before we thicken it. |
74 float mouse_move_distance_to_trigger_animation_; | 74 float mouse_move_distance_to_trigger_animation_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); | 76 DISALLOW_COPY_AND_ASSIGN(ScrollbarAnimationControllerThinning); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace cc | 79 } // namespace cc |
80 | 80 |
81 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ | 81 #endif // CC_ANIMATION_SCROLLBAR_ANIMATION_CONTROLLER_THINNING_H_ |
OLD | NEW |