Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_toolbar_button.cc

Issue 340003002: Revert of views: Move MenuButton from TextButton to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 10
12 WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener) 11 WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener)
13 : views::MenuButton(NULL, base::string16(), listener, false) { 12 : views::MenuButton(NULL, base::string16(), listener, false) {
14 wrench_icon_painter_.reset(new WrenchIconPainter(this)); 13 wrench_icon_painter_.reset(new WrenchIconPainter(this));
14
15 // Used for sizing only.
16 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance();
17 SetIcon(*rb.GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER));
15 } 18 }
16 19
17 WrenchToolbarButton::~WrenchToolbarButton() { 20 WrenchToolbarButton::~WrenchToolbarButton() {
18 } 21 }
19 22
20 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity, 23 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity,
21 bool animate) { 24 bool animate) {
22 wrench_icon_painter_->SetSeverity(severity, animate); 25 wrench_icon_painter_->SetSeverity(severity, animate);
23 } 26 }
24 27
25 gfx::Size WrenchToolbarButton::GetPreferredSize() const {
26 return ResourceBundle::GetSharedInstance().
27 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
28 }
29
30 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) { 28 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) {
31 wrench_icon_painter_->Paint( 29 wrench_icon_painter_->Paint(
32 canvas, GetThemeProvider(), gfx::Rect(size()), GetCurrentBezelType()); 30 canvas, GetThemeProvider(), gfx::Rect(size()), GetCurrentBezelType());
33 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); 31 views::Painter::PaintFocusPainter(this, canvas, focus_painter());
34 } 32 }
35 33
36 void WrenchToolbarButton::ScheduleWrenchIconPaint() { 34 void WrenchToolbarButton::ScheduleWrenchIconPaint() {
37 SchedulePaint(); 35 SchedulePaint();
38 } 36 }
39 37
40 WrenchIconPainter::BezelType WrenchToolbarButton::GetCurrentBezelType() const { 38 WrenchIconPainter::BezelType WrenchToolbarButton::GetCurrentBezelType() const {
41 switch (state()) { 39 switch (state()) {
42 case STATE_HOVERED: 40 case STATE_HOVERED:
43 return WrenchIconPainter::BEZEL_HOVER; 41 return WrenchIconPainter::BEZEL_HOVER;
44 case STATE_PRESSED: 42 case STATE_PRESSED:
45 return WrenchIconPainter::BEZEL_PRESSED; 43 return WrenchIconPainter::BEZEL_PRESSED;
46 default: 44 default:
47 return WrenchIconPainter::BEZEL_NONE; 45 return WrenchIconPainter::BEZEL_NONE;
48 } 46 }
49 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698