| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/md_text_button.h" | 5 #include "ui/views/controls/button/md_text_button.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
| 9 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
| 10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 UseMdFocusRing(); | 106 UseMdFocusRing(); |
| 107 label()->SetAutoColorReadabilityEnabled(false); | 107 label()->SetAutoColorReadabilityEnabled(false); |
| 108 } | 108 } |
| 109 | 109 |
| 110 MdTextButton::~MdTextButton() {} | 110 MdTextButton::~MdTextButton() {} |
| 111 | 111 |
| 112 void MdTextButton::UpdateColorsFromNativeTheme() { | 112 void MdTextButton::UpdateColorsFromNativeTheme() { |
| 113 ui::NativeTheme::ColorId fg_color_id = ui::NativeTheme::kColorId_NumColors; | 113 ui::NativeTheme::ColorId fg_color_id = ui::NativeTheme::kColorId_NumColors; |
| 114 switch (cta_) { | 114 switch (cta_) { |
| 115 case NO_CALL_TO_ACTION: | 115 case NO_CALL_TO_ACTION: |
| 116 fg_color_id = ui::NativeTheme::kColorId_ButtonEnabledColor; | 116 // When there's no call to action, respect a color override if one has |
| 117 // been set. For other call to action states, don't let individual buttons |
| 118 // specify a color. |
| 119 if (!explicitly_set_normal_color()) |
| 120 fg_color_id = ui::NativeTheme::kColorId_ButtonEnabledColor; |
| 117 break; | 121 break; |
| 118 case WEAK_CALL_TO_ACTION: | 122 case WEAK_CALL_TO_ACTION: |
| 119 fg_color_id = ui::NativeTheme::kColorId_CallToActionColor; | 123 fg_color_id = ui::NativeTheme::kColorId_CallToActionColor; |
| 120 break; | 124 break; |
| 121 case STRONG_CALL_TO_ACTION: | 125 case STRONG_CALL_TO_ACTION: |
| 122 fg_color_id = ui::NativeTheme::kColorId_TextOnCallToActionColor; | 126 fg_color_id = ui::NativeTheme::kColorId_TextOnCallToActionColor; |
| 123 break; | 127 break; |
| 124 } | 128 } |
| 125 ui::NativeTheme* theme = GetNativeTheme(); | 129 ui::NativeTheme* theme = GetNativeTheme(); |
| 126 SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); | 130 if (fg_color_id != ui::NativeTheme::kColorId_NumColors) |
| 131 SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); |
| 127 | 132 |
| 128 set_background( | 133 set_background( |
| 129 cta_ == STRONG_CALL_TO_ACTION | 134 cta_ == STRONG_CALL_TO_ACTION |
| 130 ? Background::CreateBackgroundPainter( | 135 ? Background::CreateBackgroundPainter( |
| 131 true, Painter::CreateSolidRoundRectPainter( | 136 true, Painter::CreateSolidRoundRectPainter( |
| 132 theme->GetSystemColor( | 137 theme->GetSystemColor( |
| 133 ui::NativeTheme::kColorId_CallToActionColor), | 138 ui::NativeTheme::kColorId_CallToActionColor), |
| 134 kInkDropSmallCornerRadius)) | 139 kInkDropSmallCornerRadius)) |
| 135 : nullptr); | 140 : nullptr); |
| 136 } | 141 } |
| 137 | 142 |
| 138 } // namespace views | 143 } // namespace views |
| OLD | NEW |