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.
5 #include "cc/animation/scrollbar_animation_controller_linear_fade.h"
7 #include "base/time/time.h"
8 #include "cc/layers/layer_impl.h"
9 #include "cc/layers/scrollbar_layer_impl_base.h"
13 scoped_ptr
<ScrollbarAnimationControllerLinearFade
>
14 ScrollbarAnimationControllerLinearFade::Create(
15 LayerImpl
* scroll_layer
,
16 ScrollbarAnimationControllerClient
* client
,
17 base::TimeDelta delay_before_starting
,
18 base::TimeDelta duration
) {
19 return make_scoped_ptr(new ScrollbarAnimationControllerLinearFade(
20 scroll_layer
, client
, delay_before_starting
, duration
));
23 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade(
24 LayerImpl
* scroll_layer
,
25 ScrollbarAnimationControllerClient
* client
,
26 base::TimeDelta delay_before_starting
,
27 base::TimeDelta duration
)
28 : ScrollbarAnimationController(client
, delay_before_starting
, duration
),
29 scroll_layer_(scroll_layer
) {
32 ScrollbarAnimationControllerLinearFade::
33 ~ScrollbarAnimationControllerLinearFade() {}
35 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress
) {
36 ApplyOpacityToScrollbars(1.f
- progress
);
41 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate() {
42 ScrollbarAnimationController::DidScrollUpdate();
43 ApplyOpacityToScrollbars(1.f
);
46 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars(
48 if (!scroll_layer_
->scrollbars())
51 LayerImpl::ScrollbarSet
* scrollbars
= scroll_layer_
->scrollbars();
52 for (LayerImpl::ScrollbarSet::iterator it
= scrollbars
->begin();
53 it
!= scrollbars
->end();
55 ScrollbarLayerImplBase
* scrollbar
= *it
;
56 if (scrollbar
->is_overlay_scrollbar())
57 scrollbar
->SetOpacity(opacity
);