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 "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/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/gfx/sys_color_change_listener.h" | 9 #include "ui/gfx/sys_color_change_listener.h" |
10 #include "ui/views/controls/button/label_button_border.h" | 10 #include "ui/views/controls/button/label_button_border.h" |
11 | 11 |
12 namespace { | |
13 | |
14 // Default shadow color for the blue button. | |
15 const SkColor kBlueButtonShadowColor = SkColorSetRGB(0x53, 0x8C, 0xEA); | |
16 | |
17 } // namespace | |
18 | |
19 namespace views { | 12 namespace views { |
20 | 13 |
21 // static | 14 // static |
22 const char BlueButton::kViewClassName[] = "views/BlueButton"; | 15 const char BlueButton::kViewClassName[] = "views/BlueButton"; |
23 | 16 |
24 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) | 17 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) |
25 : LabelButton(listener, text) { | 18 : LabelButton(listener, text) { |
26 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc. | 19 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc. |
27 SetStyle(STYLE_BUTTON); | 20 SetStyle(STYLE_BUTTON); |
28 UpdateThemedBorder(); | 21 UpdateThemedBorder(); |
29 } | 22 } |
30 | 23 |
31 BlueButton::~BlueButton() {} | 24 BlueButton::~BlueButton() {} |
32 | 25 |
33 void BlueButton::ResetColorsFromNativeTheme() { | 26 void BlueButton::ResetColorsFromNativeTheme() { |
34 LabelButton::ResetColorsFromNativeTheme(); | 27 LabelButton::ResetColorsFromNativeTheme(); |
35 if (!gfx::IsInvertedColorScheme()) { | 28 if (!gfx::IsInvertedColorScheme()) { |
36 SetTextColor(STATE_NORMAL, GetNativeTheme()-> | 29 SetTextColor(STATE_NORMAL, GetNativeTheme()-> |
37 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonEnabledColor)); | 30 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonEnabledColor)); |
38 SetTextColor(STATE_HOVERED, GetNativeTheme()-> | 31 SetTextColor(STATE_HOVERED, GetNativeTheme()-> |
39 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonHoverColor)); | 32 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonHoverColor)); |
40 SetTextColor(STATE_PRESSED, GetNativeTheme()-> | 33 SetTextColor(STATE_PRESSED, GetNativeTheme()-> |
41 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonPressedColor)); | 34 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonPressedColor)); |
42 SetTextColor(STATE_DISABLED, GetNativeTheme()-> | 35 SetTextColor(STATE_DISABLED, GetNativeTheme()-> |
43 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonDisabledColor)); | 36 GetSystemColor(ui::NativeTheme::kColorId_BlueButtonDisabledColor)); |
44 | 37 |
45 // TODO(estade): this is not great on system themes. | 38 label()->set_shadows(gfx::ShadowValues( |
46 label()->set_shadows(gfx::ShadowValues(1, | 39 1, |
47 gfx::ShadowValue(gfx::Point(0, 1), 0, kBlueButtonShadowColor))); | 40 gfx::ShadowValue( |
| 41 gfx::Point(0, 1), |
| 42 0, |
| 43 GetNativeTheme()->GetSystemColor( |
| 44 ui::NativeTheme::kColorId_BlueButtonShadowColor)))); |
48 } | 45 } |
49 } | 46 } |
50 | 47 |
51 const char* BlueButton::GetClassName() const { | 48 const char* BlueButton::GetClassName() const { |
52 return BlueButton::kViewClassName; | 49 return BlueButton::kViewClassName; |
53 } | 50 } |
54 | 51 |
55 scoped_ptr<LabelButtonBorder> BlueButton::CreateDefaultBorder() const { | 52 scoped_ptr<LabelButtonBorder> BlueButton::CreateDefaultBorder() const { |
56 // Insets for splitting the images. | 53 // Insets for splitting the images. |
57 const gfx::Insets insets(5, 5, 5, 5); | 54 const gfx::Insets insets(5, 5, 5, 5); |
(...skipping 12 matching lines...) Expand all Loading... |
70 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter( | 67 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter( |
71 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets)); | 68 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets)); |
72 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter( | 69 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter( |
73 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets)); | 70 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets)); |
74 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter( | 71 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter( |
75 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); | 72 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); |
76 return button_border.Pass(); | 73 return button_border.Pass(); |
77 } | 74 } |
78 | 75 |
79 } // namespace views | 76 } // namespace views |
OLD | NEW |