Chromium Code Reviews| 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/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 | 243 |
| 244 ui::NativeTheme* theme = GetNativeTheme(); | 244 ui::NativeTheme* theme = GetNativeTheme(); |
| 245 if (!explicitly_set_normal_color()) | 245 if (!explicitly_set_normal_color()) |
| 246 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); | 246 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); |
| 247 | 247 |
| 248 // Prominent buttons keep their enabled text color; disabled state is conveyed | 248 // Prominent buttons keep their enabled text color; disabled state is conveyed |
| 249 // by shading the background instead. | 249 // by shading the background instead. |
| 250 if (is_prominent_) | 250 if (is_prominent_) |
| 251 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); | 251 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); |
| 252 | 252 |
| 253 SkColor text_color = label()->enabled_color(); | |
| 254 SkColor bg_color = | 253 SkColor bg_color = |
| 255 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 254 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
| 256 | 255 |
| 257 if (bg_color_override_) { | 256 if (bg_color_override_) { |
| 258 bg_color = *bg_color_override_; | 257 bg_color = *bg_color_override_; |
| 259 } else if (is_prominent_) { | 258 } else if (is_prominent_) { |
| 260 bg_color = theme->GetSystemColor( | 259 bg_color = theme->GetSystemColor( |
| 261 ui::NativeTheme::kColorId_ProminentButtonColor); | 260 ui::NativeTheme::kColorId_ProminentButtonColor); |
| 262 if (state() == STATE_DISABLED) | 261 if (state() == STATE_DISABLED) |
| 263 bg_color = color_utils::BlendTowardOppositeLuma( | 262 bg_color = color_utils::BlendTowardOppositeLuma( |
| 264 bg_color, gfx::kDisabledControlAlpha); | 263 bg_color, gfx::kDisabledControlAlpha); |
| 265 } | 264 } |
| 266 | 265 |
| 267 if (state() == STATE_PRESSED) { | 266 if (state() == STATE_PRESSED) { |
| 268 SkColor shade = | 267 SkColor shade = |
| 269 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); | 268 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); |
| 270 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); | 269 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); |
| 271 } | 270 } |
| 272 | 271 |
| 273 SkColor stroke_color = | 272 SkColor stroke_color = theme->GetSystemColor( |
| 274 is_prominent_ ? SK_ColorTRANSPARENT : SkColorSetA(text_color, 0x33); | 273 is_prominent_ ? ui::NativeTheme::kColorId_ProminentButtonBorderColor |
| 274 : ui::NativeTheme::kColorId_NonProminentButtonBorderColor); | |
|
Evan Stade
2016/10/10 17:13:49
this doesn't work well for buttons that use custom
| |
| 275 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); | 275 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); |
| 276 set_background(Background::CreateBackgroundPainter( | 276 set_background(Background::CreateBackgroundPainter( |
| 277 true, Painter::CreateRoundRectWith1PxBorderPainter( | 277 true, Painter::CreateRoundRectWith1PxBorderPainter( |
| 278 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 278 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace views | 281 } // namespace views |
| OLD | NEW |