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