| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 animations.push_back(opacity_sequence.release()); | 69 animations.push_back(opacity_sequence.release()); |
| 70 animations.push_back(transform_sequence.release()); | 70 animations.push_back(transform_sequence.release()); |
| 71 layer->GetAnimator()->ScheduleTogether(animations); | 71 layer->GetAnimator()->ScheduleTogether(animations); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 namespace app_list { | 76 namespace app_list { |
| 77 | 77 |
| 78 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { | 78 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { |
| 79 SetPaintToLayer(true); | 79 SetPaintToLayer(); |
| 80 layer()->SetFillsBoundsOpaquely(false); | 80 layer()->SetFillsBoundsOpaquely(false); |
| 81 | 81 |
| 82 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); | 82 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); |
| 83 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; | 83 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; |
| 84 start_delay_timer_.Start( | 84 start_delay_timer_.Start( |
| 85 FROM_HERE, | 85 FROM_HERE, |
| 86 base::TimeDelta::FromMilliseconds(delay), | 86 base::TimeDelta::FromMilliseconds(delay), |
| 87 this, &PulsingBlockView::OnStartDelayTimer); | 87 this, &PulsingBlockView::OnStartDelayTimer); |
| 88 } | 88 } |
| 89 | 89 |
| 90 PulsingBlockView::~PulsingBlockView() { | 90 PulsingBlockView::~PulsingBlockView() { |
| 91 } | 91 } |
| 92 | 92 |
| 93 void PulsingBlockView::OnStartDelayTimer() { | 93 void PulsingBlockView::OnStartDelayTimer() { |
| 94 SchedulePulsingAnimation(layer()); | 94 SchedulePulsingAnimation(layer()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { | 97 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { |
| 98 gfx::Rect rect(GetContentsBounds()); | 98 gfx::Rect rect(GetContentsBounds()); |
| 99 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); | 99 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); |
| 100 canvas->FillRect(rect, kBlockColor); | 100 canvas->FillRect(rect, kBlockColor); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace app_list | 103 } // namespace app_list |
| OLD | NEW |