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" | 8 #include "ui/base/animation/multi_animation.h" |
9 #include "ui/base/theme_provider.h" | 9 #include "ui/base/theme_provider.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 return SEVERITY_LOW; | 66 return SEVERITY_LOW; |
67 } | 67 } |
68 | 68 |
69 WrenchIconPainter::WrenchIconPainter(Delegate* delegate) | 69 WrenchIconPainter::WrenchIconPainter(Delegate* delegate) |
70 : delegate_(delegate), | 70 : delegate_(delegate), |
71 severity_(SEVERITY_NONE) { | 71 severity_(SEVERITY_NONE) { |
72 } | 72 } |
73 | 73 |
74 WrenchIconPainter::~WrenchIconPainter() {} | 74 WrenchIconPainter::~WrenchIconPainter() {} |
75 | 75 |
76 void WrenchIconPainter::SetSeverity(Severity severity) { | 76 void WrenchIconPainter::SetSeverity(Severity severity, bool animate) { |
77 if (severity_ == severity) | 77 if (severity_ == severity) |
78 return; | 78 return; |
79 | 79 |
80 severity_ = severity; | 80 severity_ = severity; |
81 delegate_->ScheduleWrenchIconPaint(); | 81 delegate_->ScheduleWrenchIconPaint(); |
82 animation_.reset(); | 82 animation_.reset(); |
83 if (severity_ == SEVERITY_NONE) | 83 if (severity_ == SEVERITY_NONE || !animate) |
84 return; | 84 return; |
85 | 85 |
86 ui::MultiAnimation::Parts parts; | 86 ui::MultiAnimation::Parts parts; |
87 // Animate the bars left to right. | 87 // Animate the bars left to right. |
88 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 88 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); |
89 // Fade out animation. | 89 // Fade out animation. |
90 parts.push_back(ui::MultiAnimation::Part(1000, ui::Tween::EASE_IN)); | 90 parts.push_back(ui::MultiAnimation::Part(1000, ui::Tween::EASE_IN)); |
91 // Again, animate the bars left to right. | 91 // Again, animate the bars left to right. |
92 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); | 92 parts.push_back(ui::MultiAnimation::Part(1300, ui::Tween::LINEAR)); |
93 | 93 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 case SEVERITY_LOW: | 173 case SEVERITY_LOW: |
174 return IDR_TOOLS_BAR_LOW; | 174 return IDR_TOOLS_BAR_LOW; |
175 case SEVERITY_MEDIUM: | 175 case SEVERITY_MEDIUM: |
176 return IDR_TOOLS_BAR_MEDIUM; | 176 return IDR_TOOLS_BAR_MEDIUM; |
177 case SEVERITY_HIGH: | 177 case SEVERITY_HIGH: |
178 return IDR_TOOLS_BAR_HIGH; | 178 return IDR_TOOLS_BAR_HIGH; |
179 } | 179 } |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 return 0; | 181 return 0; |
182 } | 182 } |
OLD | NEW |