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
3 // found in the LICENSE file.
5 #include "ui/views/controls/button/blue_button.h"
7 #include "ui/base/resource/resource_bundle.h"
8 #include "ui/gfx/sys_color_change_listener.h"
9 #include "ui/resources/grit/ui_resources.h"
10 #include "ui/views/controls/button/label_button_border.h"
15 const char BlueButton::kViewClassName
[] = "views/BlueButton";
17 BlueButton::BlueButton(ButtonListener
* listener
, const base::string16
& text
)
18 : LabelButton(listener
, text
) {
19 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc.
20 SetStyle(STYLE_BUTTON
);
24 BlueButton::~BlueButton() {}
26 void BlueButton::ResetColorsFromNativeTheme() {
27 LabelButton::ResetColorsFromNativeTheme();
28 if (!gfx::IsInvertedColorScheme()) {
29 SetTextColor(STATE_NORMAL
, GetNativeTheme()->
30 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonEnabledColor
));
31 SetTextColor(STATE_HOVERED
, GetNativeTheme()->
32 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonHoverColor
));
33 SetTextColor(STATE_PRESSED
, GetNativeTheme()->
34 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonPressedColor
));
35 SetTextColor(STATE_DISABLED
, GetNativeTheme()->
36 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonDisabledColor
));
38 label()->SetShadows(gfx::ShadowValues(
43 GetNativeTheme()->GetSystemColor(
44 ui::NativeTheme::kColorId_BlueButtonShadowColor
))));
48 const char* BlueButton::GetClassName() const {
49 return BlueButton::kViewClassName
;
52 scoped_ptr
<LabelButtonBorder
> BlueButton::CreateDefaultBorder() const {
53 // Insets for splitting the images.
54 const gfx::Insets
insets(5, 5, 5, 5);
55 scoped_ptr
<LabelButtonBorder
> button_border(new LabelButtonBorder(style()));
56 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
57 button_border
->SetPainter(false, STATE_NORMAL
, Painter::CreateImagePainter(
58 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_NORMAL
), insets
));
59 button_border
->SetPainter(false, STATE_HOVERED
, Painter::CreateImagePainter(
60 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_HOVER
), insets
));
61 button_border
->SetPainter(false, STATE_PRESSED
, Painter::CreateImagePainter(
62 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_PRESSED
), insets
));
63 button_border
->SetPainter(false, STATE_DISABLED
, Painter::CreateImagePainter(
64 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED
), insets
));
65 button_border
->SetPainter(true, STATE_NORMAL
, Painter::CreateImagePainter(
66 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_NORMAL
), insets
));
67 button_border
->SetPainter(true, STATE_HOVERED
, Painter::CreateImagePainter(
68 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER
), insets
));
69 button_border
->SetPainter(true, STATE_PRESSED
, Painter::CreateImagePainter(
70 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED
), insets
));
71 button_border
->SetPainter(true, STATE_DISABLED
, Painter::CreateImagePainter(
72 *rb
.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED
), insets
));
73 return button_border
.Pass();