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 2679333002: [ash-md] Remove the number of animators used for the Shelf animations. (Closed)
Patch Set: Addressed comments from patch set 4. Created 3 years, 10 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
« no previous file with comments | « ash/common/wm/background_animator.h ('k') | ash/common/wm/dock/docked_window_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/wm/background_animator.h"
6
7 namespace ash {
8 namespace {
9
10 // Duration of the background animation.
11 const int kBackgroundDurationMS = 1000;
12 }
13
14 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
15 int min_alpha,
16 int max_alpha)
17 : delegate_(delegate),
18 min_alpha_(min_alpha),
19 max_alpha_(max_alpha),
20 animation_(this),
21 paints_background_(false),
22 alpha_(min_alpha) {
23 animation_.SetSlideDuration(kBackgroundDurationMS);
24 }
25
26 BackgroundAnimator::~BackgroundAnimator() {}
27
28 void BackgroundAnimator::SetDuration(int time_in_ms) {
29 animation_.SetSlideDuration(time_in_ms);
30 }
31
32 void BackgroundAnimator::Stop() {
33 animation_.Stop();
34 }
35
36 void BackgroundAnimator::SetPaintsBackground(
37 bool value,
38 BackgroundAnimatorChangeType type) {
39 if (paints_background_ == value)
40 return;
41 paints_background_ = value;
42 if (type == BACKGROUND_CHANGE_IMMEDIATE && !animation_.is_animating()) {
43 animation_.Reset(value ? 1.0f : 0.0f);
44 AnimationProgressed(&animation_);
45 AnimationEnded(&animation_);
46 return;
47 }
48 if (paints_background_)
49 animation_.Show();
50 else
51 animation_.Hide();
52 }
53
54 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) {
55 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_);
56 if (alpha_ == alpha)
57 return;
58 alpha_ = alpha;
59 delegate_->UpdateBackground(this, alpha_);
60 }
61
62 void BackgroundAnimator::AnimationEnded(const gfx::Animation* animation) {
63 delegate_->BackgroundAnimationEnded(this);
64 }
65
66 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/background_animator.h ('k') | ash/common/wm/dock/docked_window_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698