Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / animation / scrollbar_animation_controller_linear_fade.cc
blobd1049bda1cb9d18d6bb6c26552db6ca79f6e55a2
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"
11 namespace cc {
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));
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) {
38 ScrollbarAnimationControllerLinearFade::
39 ~ScrollbarAnimationControllerLinearFade() {
42 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) {
43 ApplyOpacityToScrollbars(1.f - progress);
44 client_->SetNeedsRedrawForScrollbarAnimation();
45 if (progress == 1.f)
46 StopAnimation();
49 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) {
50 ScrollbarAnimationController::DidScrollUpdate(on_resize);
51 ApplyOpacityToScrollbars(1.f);
54 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars(
55 float opacity) {
56 if (!scroll_layer_->scrollbars())
57 return;
59 LayerImpl::ScrollbarSet* scrollbars = scroll_layer_->scrollbars();
60 for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin();
61 it != scrollbars->end(); ++it) {
62 ScrollbarLayerImplBase* scrollbar = *it;
64 if (scrollbar->is_overlay_scrollbar())
65 scrollbar->SetOpacity(scrollbar->CanScrollOrientation() ? opacity : 0);
69 } // namespace cc