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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
16 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
17 #include "ui/compositor/layer_animation_element.h" | 17 #include "ui/compositor/layer_animation_element.h" |
18 #include "ui/compositor/layer_animation_sequence.h" | 18 #include "ui/compositor/layer_animation_sequence.h" |
19 #include "ui/compositor/layer_animator.h" | 19 #include "ui/compositor/layer_animator.h" |
| 20 #include "ui/compositor/layer_type.h" |
20 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/transform_util.h" | 22 #include "ui/gfx/transform_util.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const SkColor kBlockColor = SkColorSetRGB(225, 225, 225); | 26 const SkColor kBlockColor = SkColorSetRGB(225, 225, 225); |
26 const int kBlockSize = 64; | 27 const int kBlockSize = 64; |
27 | 28 |
28 const int kAnimationDurationInMs = 600; | 29 const int kAnimationDurationInMs = 600; |
29 const float kAnimationOpacity[] = { 0.4f, 0.8f, 0.4f }; | 30 const float kAnimationOpacity[] = { 0.4f, 0.8f, 0.4f }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 animations.push_back(opacity_sequence.release()); | 70 animations.push_back(opacity_sequence.release()); |
70 animations.push_back(transform_sequence.release()); | 71 animations.push_back(transform_sequence.release()); |
71 layer->GetAnimator()->ScheduleTogether(animations); | 72 layer->GetAnimator()->ScheduleTogether(animations); |
72 } | 73 } |
73 | 74 |
74 } // namespace | 75 } // namespace |
75 | 76 |
76 namespace app_list { | 77 namespace app_list { |
77 | 78 |
78 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { | 79 PulsingBlockView::PulsingBlockView(const gfx::Size& size, bool start_delay) { |
79 SetPaintToLayer(true); | 80 SetPaintToLayer(ui::LAYER_TEXTURED); |
80 layer()->SetFillsBoundsOpaquely(false); | 81 layer()->SetFillsBoundsOpaquely(false); |
81 | 82 |
82 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); | 83 const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity); |
83 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; | 84 const int delay = start_delay ? base::RandInt(0, max_delay) : 0; |
84 start_delay_timer_.Start( | 85 start_delay_timer_.Start( |
85 FROM_HERE, | 86 FROM_HERE, |
86 base::TimeDelta::FromMilliseconds(delay), | 87 base::TimeDelta::FromMilliseconds(delay), |
87 this, &PulsingBlockView::OnStartDelayTimer); | 88 this, &PulsingBlockView::OnStartDelayTimer); |
88 } | 89 } |
89 | 90 |
90 PulsingBlockView::~PulsingBlockView() { | 91 PulsingBlockView::~PulsingBlockView() { |
91 } | 92 } |
92 | 93 |
93 void PulsingBlockView::OnStartDelayTimer() { | 94 void PulsingBlockView::OnStartDelayTimer() { |
94 SchedulePulsingAnimation(layer()); | 95 SchedulePulsingAnimation(layer()); |
95 } | 96 } |
96 | 97 |
97 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { | 98 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { |
98 gfx::Rect rect(GetContentsBounds()); | 99 gfx::Rect rect(GetContentsBounds()); |
99 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); | 100 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); |
100 canvas->FillRect(rect, kBlockColor); | 101 canvas->FillRect(rect, kBlockColor); |
101 } | 102 } |
102 | 103 |
103 } // namespace app_list | 104 } // namespace app_list |
OLD | NEW |