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_utils.h" | 10 #include "ui/gfx/color_utils.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 // been set. For call to action styling, don't let individual buttons | 258 // been set. For call to action styling, don't let individual buttons |
| 259 // specify a color. | 259 // specify a color. |
| 260 ui::NativeTheme* theme = GetNativeTheme(); | 260 ui::NativeTheme* theme = GetNativeTheme(); |
| 261 if (is_cta_ || !explicitly_set_normal_color()) | 261 if (is_cta_ || !explicitly_set_normal_color()) |
| 262 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); | 262 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); |
| 263 | 263 |
| 264 SkColor text_color = label()->enabled_color(); | 264 SkColor text_color = label()->enabled_color(); |
| 265 SkColor bg_color = | 265 SkColor bg_color = |
| 266 is_cta_ | 266 is_cta_ |
| 267 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) | 267 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) |
| 268 : is_default() | 268 : is_default() |
|
sky
2016/07/26 13:31:11
Holy ternary operators Batman!
| |
| 269 ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8) | 269 ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8) |
| 270 : SK_ColorTRANSPARENT; | 270 : SK_ColorWHITE; |
| 271 | 271 |
| 272 const SkAlpha kStrokeOpacity = 0x1A; | 272 const SkAlpha kStrokeOpacity = 0x1A; |
| 273 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) | 273 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) |
| 274 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) | 274 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) |
| 275 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); | 275 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); |
| 276 | 276 |
| 277 set_background(Background::CreateBackgroundPainter( | 277 set_background(Background::CreateBackgroundPainter( |
| 278 true, Painter::CreateRoundRectWith1PxBorderPainter( | 278 true, Painter::CreateRoundRectWith1PxBorderPainter( |
| 279 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 279 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace views | 282 } // namespace views |
| OLD | NEW |