| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_linear_fade.h" | 5 #include "cc/animation/scrollbar_animation_controller_linear_fade.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 cc { | 11 namespace cc { |
| 12 | 12 |
| 13 scoped_ptr<ScrollbarAnimationControllerLinearFade> | 13 scoped_ptr<ScrollbarAnimationControllerLinearFade> |
| 14 ScrollbarAnimationControllerLinearFade::Create( | 14 ScrollbarAnimationControllerLinearFade::Create( |
| 15 LayerImpl* scroll_layer, | 15 LayerImpl* scroll_layer, |
| 16 ScrollbarAnimationControllerClient* client, | 16 ScrollbarAnimationControllerClient* client, |
| 17 base::TimeDelta delay_before_starting, | 17 base::TimeDelta delay_before_starting, |
| 18 base::TimeDelta resize_delay_before_starting, |
| 18 base::TimeDelta duration) { | 19 base::TimeDelta duration) { |
| 19 return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade( | 20 return make_scoped_ptr( |
| 20 scroll_layer, client, delay_before_starting, duration)); | 21 new ScrollbarAnimationControllerLinearFade(scroll_layer, |
| 22 client, |
| 23 delay_before_starting, |
| 24 resize_delay_before_starting, |
| 25 duration)); |
| 21 } | 26 } |
| 22 | 27 |
| 23 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade( | 28 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade( |
| 24 LayerImpl* scroll_layer, | 29 LayerImpl* scroll_layer, |
| 25 ScrollbarAnimationControllerClient* client, | 30 ScrollbarAnimationControllerClient* client, |
| 26 base::TimeDelta delay_before_starting, | 31 base::TimeDelta delay_before_starting, |
| 32 base::TimeDelta resize_delay_before_starting, |
| 27 base::TimeDelta duration) | 33 base::TimeDelta duration) |
| 28 : ScrollbarAnimationController(client, delay_before_starting, duration), | 34 : ScrollbarAnimationController(client, |
| 35 delay_before_starting, |
| 36 resize_delay_before_starting, |
| 37 duration), |
| 29 scroll_layer_(scroll_layer) { | 38 scroll_layer_(scroll_layer) { |
| 30 } | 39 } |
| 31 | 40 |
| 32 ScrollbarAnimationControllerLinearFade:: | 41 ScrollbarAnimationControllerLinearFade:: |
| 33 ~ScrollbarAnimationControllerLinearFade() {} | 42 ~ScrollbarAnimationControllerLinearFade() {} |
| 34 | 43 |
| 35 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) { | 44 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) { |
| 36 ApplyOpacityToScrollbars(1.f - progress); | 45 ApplyOpacityToScrollbars(1.f - progress); |
| 37 if (progress == 1.f) | 46 if (progress == 1.f) |
| 38 StopAnimation(); | 47 StopAnimation(); |
| 39 } | 48 } |
| 40 | 49 |
| 41 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate() { | 50 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) { |
| 42 ScrollbarAnimationController::DidScrollUpdate(); | 51 ScrollbarAnimationController::DidScrollUpdate(on_resize); |
| 43 ApplyOpacityToScrollbars(1.f); | 52 ApplyOpacityToScrollbars(1.f); |
| 44 } | 53 } |
| 45 | 54 |
| 46 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars( | 55 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars( |
| 47 float opacity) { | 56 float opacity) { |
| 48 if (!scroll_layer_->scrollbars()) | 57 if (!scroll_layer_->scrollbars()) |
| 49 return; | 58 return; |
| 50 | 59 |
| 51 LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars(); | 60 LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars(); |
| 52 for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin(); | 61 for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin(); |
| 53 it != scrollbars->end(); | 62 it != scrollbars->end(); |
| 54 ++it) { | 63 ++it) { |
| 55 ScrollbarLayerImplBase* scrollbar = *it; | 64 ScrollbarLayerImplBase* scrollbar = *it; |
| 56 if (scrollbar->is_overlay_scrollbar()) | 65 if (scrollbar->is_overlay_scrollbar()) |
| 57 scrollbar->SetOpacity(opacity); | 66 scrollbar->SetOpacity(opacity); |
| 58 } | 67 } |
| 59 } | 68 } |
| 60 | 69 |
| 61 } // namespace cc | 70 } // namespace cc |
| OLD | NEW |