OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/views/toolbar/wrench_toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/base/theme_provider.h" | 9 #include "ui/base/theme_provider.h" |
10 #include "ui/views/painter.h" | 10 #include "ui/views/painter.h" |
11 | 11 |
12 WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener) | 12 WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener) |
13 : views::MenuButton(NULL, base::string16(), listener, false) { | 13 : views::MenuButton(NULL, base::string16(), listener, false) { |
14 wrench_icon_painter_.reset(new WrenchIconPainter(this)); | 14 wrench_icon_painter_.reset(new WrenchIconPainter(this)); |
15 } | 15 } |
16 | 16 |
17 WrenchToolbarButton::~WrenchToolbarButton() { | 17 WrenchToolbarButton::~WrenchToolbarButton() { |
18 } | 18 } |
19 | 19 |
20 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity, | 20 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity, |
21 bool animate) { | 21 bool animate) { |
22 wrench_icon_painter_->SetSeverity(severity, animate); | 22 wrench_icon_painter_->SetSeverity(severity, animate); |
| 23 SchedulePaint(); |
23 } | 24 } |
24 | 25 |
25 gfx::Size WrenchToolbarButton::GetPreferredSize() const { | 26 gfx::Size WrenchToolbarButton::GetPreferredSize() const { |
26 return ResourceBundle::GetSharedInstance(). | 27 return ResourceBundle::GetSharedInstance(). |
27 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); | 28 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); |
28 } | 29 } |
29 | 30 |
30 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) { | 31 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) { |
31 views::MenuButton::OnPaint(canvas); | 32 views::MenuButton::OnPaint(canvas); |
32 wrench_icon_painter_->Paint(canvas, | 33 wrench_icon_painter_->Paint(canvas, |
33 GetThemeProvider(), | 34 GetThemeProvider(), |
34 gfx::Rect(size()), | 35 gfx::Rect(size()), |
35 WrenchIconPainter::BEZEL_NONE); | 36 WrenchIconPainter::BEZEL_NONE); |
36 } | 37 } |
37 | 38 |
38 void WrenchToolbarButton::ScheduleWrenchIconPaint() { | 39 void WrenchToolbarButton::ScheduleWrenchIconPaint() { |
39 SchedulePaint(); | 40 SchedulePaint(); |
40 } | 41 } |
OLD | NEW |