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 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 5 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
9 #include "cc/layers/scrollbar_layer_impl_base.h" | 9 #include "cc/layers/scrollbar_layer_impl_base.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 const float kIdleThicknessScale = 0.4f; | 12 const float kIdleThicknessScale = 0.4f; |
13 const float kIdleOpacity = 0.7f; | 13 const float kIdleOpacity = 0.7f; |
14 const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; | 14 const float kDefaultMouseMoveDistanceToTriggerAnimation = 25.f; |
15 } | 15 } |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 scoped_ptr<ScrollbarAnimationControllerThinning> | 19 scoped_ptr<ScrollbarAnimationControllerThinning> |
20 ScrollbarAnimationControllerThinning::Create( | 20 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 duration) { | 25 base::TimeDelta duration) { |
25 return make_scoped_ptr(new ScrollbarAnimationControllerThinning( | 26 return make_scoped_ptr( |
26 scroll_layer, client, delay_before_starting, duration)); | 27 new ScrollbarAnimationControllerThinning(scroll_layer, |
| 28 client, |
| 29 delay_before_starting, |
| 30 resize_delay_before_starting, |
| 31 duration)); |
27 } | 32 } |
28 | 33 |
29 ScrollbarAnimationControllerThinning::ScrollbarAnimationControllerThinning( | 34 ScrollbarAnimationControllerThinning::ScrollbarAnimationControllerThinning( |
30 LayerImpl* scroll_layer, | 35 LayerImpl* scroll_layer, |
31 ScrollbarAnimationControllerClient* client, | 36 ScrollbarAnimationControllerClient* client, |
32 base::TimeDelta delay_before_starting, | 37 base::TimeDelta delay_before_starting, |
| 38 base::TimeDelta resize_delay_before_starting, |
33 base::TimeDelta duration) | 39 base::TimeDelta duration) |
34 : ScrollbarAnimationController(client, delay_before_starting, duration), | 40 : ScrollbarAnimationController(client, |
| 41 delay_before_starting, |
| 42 resize_delay_before_starting, |
| 43 duration), |
35 scroll_layer_(scroll_layer), | 44 scroll_layer_(scroll_layer), |
36 mouse_is_over_scrollbar_(false), | 45 mouse_is_over_scrollbar_(false), |
37 mouse_is_near_scrollbar_(false), | 46 mouse_is_near_scrollbar_(false), |
38 thickness_change_(NONE), | 47 thickness_change_(NONE), |
39 opacity_change_(NONE), | 48 opacity_change_(NONE), |
40 mouse_move_distance_to_trigger_animation_( | 49 mouse_move_distance_to_trigger_animation_( |
41 kDefaultMouseMoveDistanceToTriggerAnimation) { | 50 kDefaultMouseMoveDistanceToTriggerAnimation) { |
42 ApplyOpacityAndThumbThicknessScale(kIdleOpacity, kIdleThicknessScale); | 51 ApplyOpacityAndThumbThicknessScale(kIdleOpacity, kIdleThicknessScale); |
43 } | 52 } |
44 | 53 |
(...skipping 13 matching lines...) Expand all Loading... |
58 } | 67 } |
59 | 68 |
60 void ScrollbarAnimationControllerThinning::DidMouseMoveOffScrollbar() { | 69 void ScrollbarAnimationControllerThinning::DidMouseMoveOffScrollbar() { |
61 mouse_is_over_scrollbar_ = false; | 70 mouse_is_over_scrollbar_ = false; |
62 mouse_is_near_scrollbar_ = false; | 71 mouse_is_near_scrollbar_ = false; |
63 opacity_change_ = DECREASE; | 72 opacity_change_ = DECREASE; |
64 thickness_change_ = DECREASE; | 73 thickness_change_ = DECREASE; |
65 StartAnimation(); | 74 StartAnimation(); |
66 } | 75 } |
67 | 76 |
68 void ScrollbarAnimationControllerThinning::DidScrollUpdate() { | 77 void ScrollbarAnimationControllerThinning::DidScrollUpdate(bool on_resize) { |
69 ScrollbarAnimationController::DidScrollUpdate(); | 78 ScrollbarAnimationController::DidScrollUpdate(on_resize); |
70 ApplyOpacityAndThumbThicknessScale( | 79 ApplyOpacityAndThumbThicknessScale( |
71 1, mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale); | 80 1, mouse_is_near_scrollbar_ ? 1.f : kIdleThicknessScale); |
72 | 81 |
73 if (!mouse_is_over_scrollbar_) | 82 if (!mouse_is_over_scrollbar_) |
74 opacity_change_ = DECREASE; | 83 opacity_change_ = DECREASE; |
75 } | 84 } |
76 | 85 |
77 void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) { | 86 void ScrollbarAnimationControllerThinning::DidMouseMoveNear(float distance) { |
78 bool mouse_is_over_scrollbar = distance == 0.0; | 87 bool mouse_is_over_scrollbar = distance == 0.0; |
79 bool mouse_is_near_scrollbar = | 88 bool mouse_is_near_scrollbar = |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 AdjustScale(opacity, scrollbar->opacity(), opacity_change_)); | 149 AdjustScale(opacity, scrollbar->opacity(), opacity_change_)); |
141 scrollbar->SetThumbThicknessScaleFactor( | 150 scrollbar->SetThumbThicknessScaleFactor( |
142 AdjustScale(thumb_thickness_scale, | 151 AdjustScale(thumb_thickness_scale, |
143 scrollbar->thumb_thickness_scale_factor(), | 152 scrollbar->thumb_thickness_scale_factor(), |
144 thickness_change_)); | 153 thickness_change_)); |
145 } | 154 } |
146 } | 155 } |
147 } | 156 } |
148 | 157 |
149 } // namespace cc | 158 } // namespace cc |
OLD | NEW |