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

Side by Side Diff: ui/views/controls/button/blue_button.cc

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 6 years, 11 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
« no previous file with comments | « ui/views/color_chooser/color_chooser_view.cc ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/controls/button/blue_button.h" 5 #include "ui/views/controls/button/blue_button.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "ui/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/sys_color_change_listener.h" 10 #include "ui/gfx/sys_color_change_listener.h"
(...skipping 12 matching lines...) Expand all
23 // static 23 // static
24 const char BlueButton::kViewClassName[] = "views/BlueButton"; 24 const char BlueButton::kViewClassName[] = "views/BlueButton";
25 25
26 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) 26 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text)
27 : LabelButton(listener, text) { 27 : LabelButton(listener, text) {
28 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc. 28 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc.
29 SetStyle(STYLE_BUTTON); 29 SetStyle(STYLE_BUTTON);
30 30
31 // Insets for splitting the images. 31 // Insets for splitting the images.
32 const gfx::Insets insets(5, 5, 5, 5); 32 const gfx::Insets insets(5, 5, 5, 5);
33 LabelButtonBorder* button_border = new LabelButtonBorder(style()); 33 scoped_ptr<LabelButtonBorder> button_border(new LabelButtonBorder(style()));
34 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 34 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
35 button_border->SetPainter(false, STATE_NORMAL, Painter::CreateImagePainter( 35 button_border->SetPainter(false, STATE_NORMAL, Painter::CreateImagePainter(
36 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_NORMAL), insets)); 36 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_NORMAL), insets));
37 button_border->SetPainter(false, STATE_HOVERED, Painter::CreateImagePainter( 37 button_border->SetPainter(false, STATE_HOVERED, Painter::CreateImagePainter(
38 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_HOVER), insets)); 38 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_HOVER), insets));
39 button_border->SetPainter(false, STATE_PRESSED, Painter::CreateImagePainter( 39 button_border->SetPainter(false, STATE_PRESSED, Painter::CreateImagePainter(
40 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_PRESSED), insets)); 40 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_PRESSED), insets));
41 button_border->SetPainter(false, STATE_DISABLED, Painter::CreateImagePainter( 41 button_border->SetPainter(false, STATE_DISABLED, Painter::CreateImagePainter(
42 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); 42 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets));
43 button_border->SetPainter(true, STATE_NORMAL, Painter::CreateImagePainter( 43 button_border->SetPainter(true, STATE_NORMAL, Painter::CreateImagePainter(
44 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_NORMAL), insets)); 44 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_NORMAL), insets));
45 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter( 45 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter(
46 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets)); 46 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets));
47 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter( 47 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter(
48 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets)); 48 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets));
49 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter( 49 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter(
50 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); 50 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets));
51 set_border(button_border); 51 SetBorder(button_border.PassAs<Border>());
52 } 52 }
53 53
54 BlueButton::~BlueButton() {} 54 BlueButton::~BlueButton() {}
55 55
56 void BlueButton::ResetColorsFromNativeTheme() { 56 void BlueButton::ResetColorsFromNativeTheme() {
57 LabelButton::ResetColorsFromNativeTheme(); 57 LabelButton::ResetColorsFromNativeTheme();
58 if (!gfx::IsInvertedColorScheme()) { 58 if (!gfx::IsInvertedColorScheme()) {
59 for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state) 59 for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state)
60 SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor); 60 SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor);
61 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor); 61 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor);
62 label()->SetShadowOffset(0, 1); 62 label()->SetShadowOffset(0, 1);
63 } 63 }
64 } 64 }
65 65
66 const char* BlueButton::GetClassName() const { 66 const char* BlueButton::GetClassName() const {
67 return BlueButton::kViewClassName; 67 return BlueButton::kViewClassName;
68 } 68 }
69 69
70 } // namespace views 70 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/color_chooser/color_chooser_view.cc ('k') | ui/views/controls/button/checkbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698