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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 SetBorder(CreateEmptyBorder(top_padding, kHorizontalPadding, bottom_padding, | 244 SetBorder(CreateEmptyBorder(top_padding, kHorizontalPadding, bottom_padding, |
245 kHorizontalPadding)); | 245 kHorizontalPadding)); |
246 } | 246 } |
247 | 247 |
248 void MdTextButton::UpdateColors() { | 248 void MdTextButton::UpdateColors() { |
249 ui::NativeTheme::ColorId fg_color_id = | 249 ui::NativeTheme::ColorId fg_color_id = |
250 is_prominent_ ? ui::NativeTheme::kColorId_TextOnProminentButtonColor | 250 is_prominent_ ? ui::NativeTheme::kColorId_TextOnProminentButtonColor |
251 : ui::NativeTheme::kColorId_ButtonEnabledColor; | 251 : ui::NativeTheme::kColorId_ButtonEnabledColor; |
252 | 252 |
253 ui::NativeTheme* theme = GetNativeTheme(); | 253 ui::NativeTheme* theme = GetNativeTheme(); |
254 if (!explicitly_set_normal_color()) | 254 if (!explicitly_set_normal_color()) { |
| 255 const auto colors = explicitly_set_colors(); |
255 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); | 256 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); |
| 257 set_explicitly_set_colors(colors); |
| 258 } |
256 | 259 |
257 // Prominent buttons keep their enabled text color; disabled state is conveyed | 260 // Prominent buttons keep their enabled text color; disabled state is conveyed |
258 // by shading the background instead. | 261 // by shading the background instead. |
259 if (is_prominent_) | 262 if (is_prominent_) |
260 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); | 263 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); |
261 | 264 |
262 SkColor text_color = label()->enabled_color(); | 265 SkColor text_color = label()->enabled_color(); |
263 SkColor bg_color = | 266 SkColor bg_color = |
264 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 267 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
265 | 268 |
(...skipping 28 matching lines...) Expand all Loading... |
294 stroke_color, gfx::kDisabledControlAlpha); | 297 stroke_color, gfx::kDisabledControlAlpha); |
295 } | 298 } |
296 | 299 |
297 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); | 300 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); |
298 set_background(Background::CreateBackgroundPainter( | 301 set_background(Background::CreateBackgroundPainter( |
299 true, Painter::CreateRoundRectWith1PxBorderPainter( | 302 true, Painter::CreateRoundRectWith1PxBorderPainter( |
300 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 303 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
301 } | 304 } |
302 | 305 |
303 } // namespace views | 306 } // namespace views |
OLD | NEW |