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

Side by Side Diff: ash/launcher/background_animator.cc

Issue 12313118: Refactor: Shelf Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: safer shutdown (status_area_widget_) Created 7 years, 9 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/launcher/background_animator.h ('k') | ash/launcher/launcher.h » ('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/launcher/background_animator.h"
6
7
8 namespace ash {
9 namespace internal {
10
11 namespace {
12
13 // Duration of the background animation.
14 const int kBackgroundDurationMS = 1000;
15
16 }
17
18 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
19 int min_alpha,
20 int max_alpha)
21 : delegate_(delegate),
22 min_alpha_(min_alpha),
23 max_alpha_(max_alpha),
24 ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)),
25 paints_background_(false),
26 alpha_(min_alpha) {
27 animation_.SetSlideDuration(kBackgroundDurationMS);
28 }
29
30 BackgroundAnimator::~BackgroundAnimator() {
31 }
32
33 void BackgroundAnimator::SetPaintsBackground(bool value, ChangeType type) {
34 if (paints_background_ == value)
35 return;
36 paints_background_ = value;
37 if (type == CHANGE_IMMEDIATE && !animation_.is_animating()) {
38 animation_.Reset(value ? 1.0f : 0.0f);
39 AnimationProgressed(&animation_);
40 return;
41 }
42 if (paints_background_)
43 animation_.Show();
44 else
45 animation_.Hide();
46 }
47
48 void BackgroundAnimator::AnimationProgressed(const ui::Animation* animation) {
49 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_);
50 if (alpha_ == alpha)
51 return;
52 alpha_ = alpha;
53 delegate_->UpdateBackground(alpha_);
54 }
55
56 } // namespace internal
57 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/background_animator.h ('k') | ash/launcher/launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698