OLD | NEW |
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 "ui/app_list/views/pulsing_block_view.h" | 5 #include "ui/app_list/views/pulsing_block_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 animations.push_back(opacity_sequence.release()); | 64 animations.push_back(opacity_sequence.release()); |
65 animations.push_back(transform_sequence.release()); | 65 animations.push_back(transform_sequence.release()); |
66 layer->GetAnimator()->ScheduleTogether(animations); | 66 layer->GetAnimator()->ScheduleTogether(animations); |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 namespace app_list { | 71 namespace app_list { |
72 | 72 |
73 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { | 73 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { |
74 #if defined(USE_AURA) | |
75 SetPaintToLayer(true); | 74 SetPaintToLayer(true); |
76 SetFillsBoundsOpaquely(false); | 75 SetFillsBoundsOpaquely(false); |
77 | 76 |
78 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); | 77 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); |
79 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; | 78 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; |
80 start_delay_timer_.Start( | 79 start_delay_timer_.Start( |
81 FROM_HERE, | 80 FROM_HERE, |
82 base::TimeDelta::FromMilliseconds(delay), | 81 base::TimeDelta::FromMilliseconds(delay), |
83 this, &PulsingBlockView::OnStartDelayTimer); | 82 this, &PulsingBlockView::OnStartDelayTimer); |
84 #else | |
85 NOTREACHED() << "Pulsing animation is not supported on Windows"; | |
86 #endif | |
87 } | 83 } |
88 | 84 |
89 PulsingBlockView::~PulsingBlockView() { | 85 PulsingBlockView::~PulsingBlockView() { |
90 } | 86 } |
91 | 87 |
92 void PulsingBlockView::OnStartDelayTimer() { | 88 void PulsingBlockView::OnStartDelayTimer() { |
93 SchedulePulsingAnimation(layer()); | 89 SchedulePulsingAnimation(layer()); |
94 } | 90 } |
95 | 91 |
96 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { | 92 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { |
97 gfx::Rect rect(GetContentsBounds()); | 93 gfx::Rect rect(GetContentsBounds()); |
98 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); | 94 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); |
99 canvas->FillRect(rect, kBlockColor); | 95 canvas->FillRect(rect, kBlockColor); |
100 } | 96 } |
101 | 97 |
102 } // namespace app_list | 98 } // namespace app_list |
OLD | NEW |