Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / controls / button / blue_button.cc
blob8bae234303b8235b84baeaeb8ccaf15ba4aa664e
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"
12 namespace views {
14 // static
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);
21 UpdateThemedBorder();
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(
40 gfx::ShadowValue(
41 gfx::Point(0, 1),
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();
76 } // namespace views