Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: ash/common/wm/background_animator.cc

Issue 2053113002: Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved ash/test/material_design_controller_test_api.(h|cc) to ash/common/material_design/test/. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ash/common/wm/background_animator.h" 5 #include "ash/common/wm/background_animator.h"
6 6
7 namespace ash { 7 namespace ash {
8 namespace { 8 namespace {
9 9
10 // Duration of the background animation. 10 // Duration of the background animation.
11 const int kBackgroundDurationMS = 1000; 11 const int kBackgroundDurationMS = 1000;
12 } 12 }
13 13
14 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate, 14 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
15 int min_alpha, 15 int min_alpha,
16 int max_alpha) 16 int max_alpha)
17 : delegate_(delegate), 17 : delegate_(delegate),
18 min_alpha_(min_alpha), 18 min_alpha_(min_alpha),
19 max_alpha_(max_alpha), 19 max_alpha_(max_alpha),
20 animation_(this), 20 animation_(this),
21 paints_background_(false), 21 paints_background_(false),
22 alpha_(min_alpha) { 22 alpha_(-1) {
23 animation_.SetSlideDuration(kBackgroundDurationMS); 23 animation_.SetSlideDuration(kBackgroundDurationMS);
24 } 24 }
25 25
26 BackgroundAnimator::~BackgroundAnimator() {} 26 BackgroundAnimator::~BackgroundAnimator() {}
27 27
28 void BackgroundAnimator::SetDuration(int time_in_ms) { 28 void BackgroundAnimator::SetDuration(int time_in_ms) {
29 animation_.SetSlideDuration(time_in_ms); 29 animation_.SetSlideDuration(time_in_ms);
30 } 30 }
31 31
32 void BackgroundAnimator::Stop() {
33 animation_.Stop();
34 }
35
32 void BackgroundAnimator::SetPaintsBackground( 36 void BackgroundAnimator::SetPaintsBackground(
33 bool value, 37 bool value,
34 BackgroundAnimatorChangeType type) { 38 BackgroundAnimatorChangeType type) {
35 if (paints_background_ == value) 39 if (paints_background_ == value)
36 return; 40 return;
37 paints_background_ = value; 41 paints_background_ = value;
38 if (type == BACKGROUND_CHANGE_IMMEDIATE && !animation_.is_animating()) { 42 if (type == BACKGROUND_CHANGE_IMMEDIATE && !animation_.is_animating()) {
39 animation_.Reset(value ? 1.0f : 0.0f); 43 animation_.Reset(value ? 1.0f : 0.0f);
40 AnimationProgressed(&animation_); 44 AnimationProgressed(&animation_);
45 AnimationEnded(&animation_);
41 return; 46 return;
42 } 47 }
43 if (paints_background_) 48 if (paints_background_)
44 animation_.Show(); 49 animation_.Show();
45 else 50 else
46 animation_.Hide(); 51 animation_.Hide();
47 } 52 }
48 53
49 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) { 54 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) {
50 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_); 55 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_);
51 if (alpha_ == alpha) 56 if (alpha_ == alpha)
52 return; 57 return;
53 alpha_ = alpha; 58 alpha_ = alpha;
54 delegate_->UpdateBackground(alpha_); 59 delegate_->UpdateBackground(this, alpha_);
60 }
61
62 void BackgroundAnimator::AnimationEnded(const gfx::Animation* animation) {
63 delegate_->BackgroundAnimationEnded(this, true);
64 }
65
66 void BackgroundAnimator::AnimationCanceled(const gfx::Animation* animation) {
67 delegate_->BackgroundAnimationEnded(this, false);
55 } 68 }
56 69
57 } // namespace ash 70 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698