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_utils.h" | 11 #include "ui/gfx/color_utils.h" |
11 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
12 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
13 #include "ui/views/animation/ink_drop_highlight.h" | 14 #include "ui/views/animation/ink_drop_highlight.h" |
14 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" | 15 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" |
15 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
16 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
17 #include "ui/views/controls/button/blue_button.h" | 18 #include "ui/views/controls/button/blue_button.h" |
18 #include "ui/views/painter.h" | 19 #include "ui/views/painter.h" |
19 #include "ui/views/style/platform_style.h" | 20 #include "ui/views/style/platform_style.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 SkColor text_color = label()->enabled_color(); | 301 SkColor text_color = label()->enabled_color(); |
301 SkColor bg_color = | 302 SkColor bg_color = |
302 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 303 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
303 | 304 |
304 if (bg_color_override_) { | 305 if (bg_color_override_) { |
305 bg_color = *bg_color_override_; | 306 bg_color = *bg_color_override_; |
306 } else if (is_cta_) { | 307 } else if (is_cta_) { |
307 bg_color = theme->GetSystemColor( | 308 bg_color = theme->GetSystemColor( |
308 ui::NativeTheme::kColorId_CallToActionColor); | 309 ui::NativeTheme::kColorId_CallToActionColor); |
309 if (state() == STATE_DISABLED) | 310 if (state() == STATE_DISABLED) |
310 bg_color = color_utils::BlendTowardOppositeLuma(bg_color, 0x61); | 311 bg_color = color_utils::BlendTowardOppositeLuma( |
| 312 bg_color, gfx::kDisabledControlAlpha); |
311 } else if (is_default()) { | 313 } else if (is_default()) { |
312 bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8); | 314 bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8); |
313 } | 315 } |
314 | 316 |
315 if (state() == STATE_PRESSED) { | 317 if (state() == STATE_PRESSED) { |
316 SkColor shade = | 318 SkColor shade = |
317 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); | 319 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); |
318 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); | 320 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); |
319 } | 321 } |
320 | 322 |
321 const SkAlpha kStrokeOpacity = 0x1A; | 323 const SkAlpha kStrokeOpacity = 0x1A; |
322 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) | 324 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) |
323 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) | 325 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) |
324 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); | 326 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); |
325 | 327 |
326 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); | 328 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); |
327 set_background(Background::CreateBackgroundPainter( | 329 set_background(Background::CreateBackgroundPainter( |
328 true, Painter::CreateRoundRectWith1PxBorderPainter( | 330 true, Painter::CreateRoundRectWith1PxBorderPainter( |
329 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 331 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
330 } | 332 } |
331 | 333 |
332 } // namespace views | 334 } // namespace views |
OLD | NEW |