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

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

Issue 1921353002: Moves handful of files to ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shell_ids
Patch Set: merge to trunk Created 4 years, 8 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/shelf/background_animator.h ('k') | ash/shelf/shelf_layout_manager.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/shelf/background_animator.h"
6
7 namespace ash {
8 namespace {
9
10 // Duration of the background animation.
11 const int kBackgroundDurationMS = 1000;
12
13 }
14
15 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
16 int min_alpha,
17 int max_alpha)
18 : delegate_(delegate),
19 min_alpha_(min_alpha),
20 max_alpha_(max_alpha),
21 animation_(this),
22 paints_background_(false),
23 alpha_(min_alpha) {
24 animation_.SetSlideDuration(kBackgroundDurationMS);
25 }
26
27 BackgroundAnimator::~BackgroundAnimator() {
28 }
29
30 void BackgroundAnimator::SetDuration(int time_in_ms) {
31 animation_.SetSlideDuration(time_in_ms);
32 }
33
34 void BackgroundAnimator::SetPaintsBackground(
35 bool value, BackgroundAnimatorChangeType type) {
36 if (paints_background_ == value)
37 return;
38 paints_background_ = value;
39 if (type == BACKGROUND_CHANGE_IMMEDIATE && !animation_.is_animating()) {
40 animation_.Reset(value ? 1.0f : 0.0f);
41 AnimationProgressed(&animation_);
42 return;
43 }
44 if (paints_background_)
45 animation_.Show();
46 else
47 animation_.Hide();
48 }
49
50 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) {
51 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_);
52 if (alpha_ == alpha)
53 return;
54 alpha_ = alpha;
55 delegate_->UpdateBackground(alpha_);
56 }
57
58 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/background_animator.h ('k') | ash/shelf/shelf_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698