Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ui/views/controls/button/md_text_button.cc

Issue 2187473004: Make normal MD text buttons *on infobars* white. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 bottom_padding - inbuilt_bottom_padding, kHorizontalPadding)); 247 bottom_padding - inbuilt_bottom_padding, kHorizontalPadding));
248 } 248 }
249 249
250 MdTextButton::~MdTextButton() {} 250 MdTextButton::~MdTextButton() {}
251 251
252 void MdTextButton::UpdateColors() { 252 void MdTextButton::UpdateColors() {
253 ui::NativeTheme::ColorId fg_color_id = 253 ui::NativeTheme::ColorId fg_color_id =
254 is_cta_ ? ui::NativeTheme::kColorId_TextOnCallToActionColor 254 is_cta_ ? ui::NativeTheme::kColorId_TextOnCallToActionColor
255 : ui::NativeTheme::kColorId_ButtonEnabledColor; 255 : ui::NativeTheme::kColorId_ButtonEnabledColor;
256 256
257 // When there's no call to action, respect a color override if one has
258 // been set. For call to action styling, don't let individual buttons
259 // specify a color.
260 ui::NativeTheme* theme = GetNativeTheme(); 257 ui::NativeTheme* theme = GetNativeTheme();
261 if (is_cta_ || !explicitly_set_normal_color()) 258 if (!explicitly_set_normal_color())
262 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); 259 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id));
263 260
264 SkColor text_color = label()->enabled_color(); 261 SkColor text_color = label()->enabled_color();
265 SkColor bg_color = 262 SkColor bg_color =
266 is_cta_ 263 bg_color_override_
sky 2016/07/26 23:27:27 I'm happy you found a way to make this more impene
Evan Stade 2016/07/26 23:29:56 I heard you like ternaries! Personally I think th
267 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) 264 ? *bg_color_override_
268 : is_default() 265 : is_cta_
269 ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8) 266 ? theme->GetSystemColor(
270 : SK_ColorWHITE; 267 ui::NativeTheme::kColorId_CallToActionColor)
268 : is_default()
269 ? color_utils::BlendTowardOppositeLuma(text_color, 0xD8)
270 : SK_ColorTRANSPARENT;
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
OLDNEW
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698