OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/toolbar/wrench_icon_painter.h" | 5 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/animation/multi_animation.h" | |
9 #include "ui/base/theme_provider.h" | 8 #include "ui/base/theme_provider.h" |
| 9 #include "ui/gfx/animation/multi_animation.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // The wrench icon is made up of this many bars stacked vertically. | 16 // The wrench icon is made up of this many bars stacked vertically. |
17 const int kBarCount = 3; | 17 const int kBarCount = 3; |
18 | 18 |
19 // |value| is the animation progress from 0 to 1. |index| is the index of the | 19 // |value| is the animation progress from 0 to 1. |index| is the index of the |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void WrenchIconPainter::SetSeverity(Severity severity, bool animate) { | 81 void WrenchIconPainter::SetSeverity(Severity severity, bool animate) { |
82 if (severity_ == severity) | 82 if (severity_ == severity) |
83 return; | 83 return; |
84 | 84 |
85 severity_ = severity; | 85 severity_ = severity; |
86 delegate_->ScheduleWrenchIconPaint(); | 86 delegate_->ScheduleWrenchIconPaint(); |
87 animation_.reset(); | 87 animation_.reset(); |
88 if (severity_ == SEVERITY_NONE || !animate) | 88 if (severity_ == SEVERITY_NONE || !animate) |
89 return; | 89 return; |
90 | 90 |
91 ui::MultiAnimation::Parts parts; | 91 gfx::MultiAnimation::Parts parts; |
92 // Animate the bars left to right. | 92 // Animate the bars left to right. |
93 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 93 parts.push_back(gfx::MultiAnimation::Part(1300, gfx::Tween::LINEAR)); |
94 // Fade out animation. | 94 // Fade out animation. |
95 parts.push_back(ui::MultiAnimation::Part(1000, ui::Tween::EASE_IN)); | 95 parts.push_back(gfx::MultiAnimation::Part(1000, gfx::Tween::EASE_IN)); |
96 // Again, animate the bars left to right. | 96 // Again, animate the bars left to right. |
97 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 97 parts.push_back(gfx::MultiAnimation::Part(1300, gfx::Tween::LINEAR)); |
98 | 98 |
99 animation_.reset( | 99 animation_.reset( |
100 new ui::MultiAnimation(parts, base::TimeDelta::FromMilliseconds(40))); | 100 new gfx::MultiAnimation(parts, base::TimeDelta::FromMilliseconds(40))); |
101 animation_->set_delegate(this); | 101 animation_->set_delegate(this); |
102 animation_->set_continuous(false); | 102 animation_->set_continuous(false); |
103 animation_->Start(); | 103 animation_->Start(); |
104 } | 104 } |
105 | 105 |
106 void WrenchIconPainter::Paint(gfx::Canvas* canvas, | 106 void WrenchIconPainter::Paint(gfx::Canvas* canvas, |
107 ui::ThemeProvider* theme_provider, | 107 ui::ThemeProvider* theme_provider, |
108 const gfx::Rect& rect, | 108 const gfx::Rect& rect, |
109 BezelType bezel_type) { | 109 BezelType bezel_type) { |
110 gfx::Point center = rect.CenterPoint(); | 110 gfx::Point center = rect.CenterPoint(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 canvas->DrawImageInt(*image, 0, 0, width, image->height(), | 160 canvas->DrawImageInt(*image, 0, 0, width, image->height(), |
161 x, y, width, image->height(), false, paint); | 161 x, y, width, image->height(), false, paint); |
162 y += image->height(); | 162 y += image->height(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 if (!badge_.isNull()) | 166 if (!badge_.isNull()) |
167 canvas->DrawImageInt(badge_, 0, 0); | 167 canvas->DrawImageInt(badge_, 0, 0); |
168 } | 168 } |
169 | 169 |
170 void WrenchIconPainter::AnimationProgressed(const ui::Animation* animation) { | 170 void WrenchIconPainter::AnimationProgressed(const gfx::Animation* animation) { |
171 delegate_->ScheduleWrenchIconPaint(); | 171 delegate_->ScheduleWrenchIconPaint(); |
172 } | 172 } |
173 | 173 |
174 int WrenchIconPainter::GetCurrentSeverityImageID() const { | 174 int WrenchIconPainter::GetCurrentSeverityImageID() const { |
175 switch (severity_) { | 175 switch (severity_) { |
176 case SEVERITY_NONE: | 176 case SEVERITY_NONE: |
177 return 0; | 177 return 0; |
178 case SEVERITY_LOW: | 178 case SEVERITY_LOW: |
179 return IDR_TOOLS_BAR_LOW; | 179 return IDR_TOOLS_BAR_LOW; |
180 case SEVERITY_MEDIUM: | 180 case SEVERITY_MEDIUM: |
181 return IDR_TOOLS_BAR_MEDIUM; | 181 return IDR_TOOLS_BAR_MEDIUM; |
182 case SEVERITY_HIGH: | 182 case SEVERITY_HIGH: |
183 return IDR_TOOLS_BAR_HIGH; | 183 return IDR_TOOLS_BAR_HIGH; |
184 } | 184 } |
185 NOTREACHED(); | 185 NOTREACHED(); |
186 return 0; | 186 return 0; |
187 } | 187 } |
OLD | NEW |