Chromium Code Reviews| 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 { | 12 namespace { |
| 13 | 13 |
| 14 // Default text and shadow colors for the blue button. | 14 // Default shadow color for the blue button. |
| 15 const SkColor kBlueButtonTextColor = SK_ColorWHITE; | |
| 16 const SkColor kBlueButtonShadowColor = SkColorSetRGB(0x53, 0x8C, 0xEA); | 15 const SkColor kBlueButtonShadowColor = SkColorSetRGB(0x53, 0x8C, 0xEA); |
| 17 | 16 |
| 18 } // namespace | 17 } // namespace |
| 19 | 18 |
| 20 namespace views { | 19 namespace views { |
| 21 | 20 |
| 22 // static | 21 // static |
| 23 const char BlueButton::kViewClassName[] = "views/BlueButton"; | 22 const char BlueButton::kViewClassName[] = "views/BlueButton"; |
| 24 | 23 |
| 25 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) | 24 BlueButton::BlueButton(ButtonListener* listener, const base::string16& text) |
| 26 : LabelButton(listener, text) { | 25 : LabelButton(listener, text) { |
| 27 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc. | 26 // Inherit STYLE_BUTTON insets, minimum size, alignment, etc. |
| 28 SetStyle(STYLE_BUTTON); | 27 SetStyle(STYLE_BUTTON); |
| 29 UpdateThemedBorder(); | 28 UpdateThemedBorder(); |
|
msw
2014/06/03 02:10:10
If we want these buttons to be blue, can't we just
| |
| 30 } | 29 } |
| 31 | 30 |
| 32 BlueButton::~BlueButton() {} | 31 BlueButton::~BlueButton() {} |
| 33 | 32 |
| 34 void BlueButton::ResetColorsFromNativeTheme() { | 33 void BlueButton::ResetColorsFromNativeTheme() { |
| 35 LabelButton::ResetColorsFromNativeTheme(); | 34 LabelButton::ResetColorsFromNativeTheme(); |
| 36 if (!gfx::IsInvertedColorScheme()) { | 35 if (!gfx::IsInvertedColorScheme()) { |
| 37 for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state) | 36 SetTextColor(STATE_NORMAL, GetNativeTheme()-> |
| 38 SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor); | 37 GetSystemColor( |
| 38 ui::NativeTheme::kColorId_CallToActionButtonEnabledColor)); | |
| 39 SetTextColor(STATE_HOVERED, GetNativeTheme()-> | |
| 40 GetSystemColor( | |
| 41 ui::NativeTheme::kColorId_CallToActionButtonHoverColor)); | |
| 42 SetTextColor(STATE_PRESSED, GetNativeTheme()-> | |
| 43 GetSystemColor( | |
| 44 ui::NativeTheme::kColorId_CallToActionButtonHighlightColor)); | |
| 45 SetTextColor(STATE_DISABLED, GetNativeTheme()-> | |
| 46 GetSystemColor( | |
| 47 ui::NativeTheme::kColorId_CallToActionButtonDisabledColor)); | |
| 48 | |
| 49 // TODO(estade): this is not great on system themes. | |
|
msw
2014/06/02 21:06:20
Perhaps we could use a partially transparent versi
Evan Stade
2014/06/02 22:18:14
I'd be inclined to have no shadow on gtk system th
| |
| 39 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor); | 50 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor); |
| 40 label()->SetShadowOffset(0, 1); | 51 label()->SetShadowOffset(0, 1); |
| 41 } | 52 } |
| 42 } | 53 } |
| 43 | 54 |
| 44 const char* BlueButton::GetClassName() const { | 55 const char* BlueButton::GetClassName() const { |
| 45 return BlueButton::kViewClassName; | 56 return BlueButton::kViewClassName; |
| 46 } | 57 } |
| 47 | 58 |
| 48 scoped_ptr<LabelButtonBorder> BlueButton::CreateDefaultBorder() const { | 59 scoped_ptr<LabelButtonBorder> BlueButton::CreateDefaultBorder() const { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 63 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter( | 74 button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter( |
| 64 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets)); | 75 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets)); |
| 65 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter( | 76 button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter( |
| 66 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets)); | 77 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets)); |
| 67 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter( | 78 button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter( |
| 68 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); | 79 *rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets)); |
| 69 return button_border.Pass(); | 80 return button_border.Pass(); |
| 70 } | 81 } |
| 71 | 82 |
| 72 } // namespace views | 83 } // namespace views |
| OLD | NEW |