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_utils.h" | 10 #include "ui/gfx/color_utils.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 bg_color = *bg_color_override_; | 305 bg_color = *bg_color_override_; |
306 } else if (is_cta_) { | 306 } else if (is_cta_) { |
307 bg_color = theme->GetSystemColor( | 307 bg_color = theme->GetSystemColor( |
308 ui::NativeTheme::kColorId_CallToActionColor); | 308 ui::NativeTheme::kColorId_CallToActionColor); |
309 if (state() == STATE_DISABLED) | 309 if (state() == STATE_DISABLED) |
310 bg_color = color_utils::BlendTowardOppositeLuma(bg_color, 0x61); | 310 bg_color = color_utils::BlendTowardOppositeLuma(bg_color, 0x61); |
311 } else if (is_default()) { | 311 } else if (is_default()) { |
312 bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8); | 312 bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8); |
313 } | 313 } |
314 | 314 |
315 // TODO(ellyjones): Excise this, in favor of a helper function wrapping | 315 if (state() == STATE_PRESSED) { |
316 // |color_utils::AlphaBlend| and a new NativeTheme color constant. | 316 SkColor shade = |
317 bg_color = PlatformStyle::BackgroundColorForMdButton(bg_color, state()); | 317 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); |
| 318 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); |
| 319 } |
318 | 320 |
319 const SkAlpha kStrokeOpacity = 0x1A; | 321 const SkAlpha kStrokeOpacity = 0x1A; |
320 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) | 322 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) |
321 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) | 323 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) |
322 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); | 324 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); |
323 | 325 |
324 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); | 326 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); |
325 set_background(Background::CreateBackgroundPainter( | 327 set_background(Background::CreateBackgroundPainter( |
326 true, Painter::CreateRoundRectWith1PxBorderPainter( | 328 true, Painter::CreateRoundRectWith1PxBorderPainter( |
327 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 329 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
328 } | 330 } |
329 | 331 |
330 } // namespace views | 332 } // namespace views |
OLD | NEW |