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

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

Issue 2957263002: Update dialog button text color for Harmony per the latest button spec (Closed)
Patch Set: color_utils::IsInvertedColorScheme(), fewer Win constants Created 3 years, 5 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
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 "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // TODO(estade): can we get rid of the platform style border hoopla if 232 // TODO(estade): can we get rid of the platform style border hoopla if
233 // we apply the MD treatment to all buttons, even GTK buttons? 233 // we apply the MD treatment to all buttons, even GTK buttons?
234 const int horizontal_padding = LayoutProvider::Get()->GetDistanceMetric( 234 const int horizontal_padding = LayoutProvider::Get()->GetDistanceMetric(
235 DISTANCE_BUTTON_HORIZONTAL_PADDING); 235 DISTANCE_BUTTON_HORIZONTAL_PADDING);
236 SetBorder(CreateEmptyBorder(top_padding, horizontal_padding, bottom_padding, 236 SetBorder(CreateEmptyBorder(top_padding, horizontal_padding, bottom_padding,
237 horizontal_padding)); 237 horizontal_padding));
238 } 238 }
239 239
240 void MdTextButton::UpdateColors() { 240 void MdTextButton::UpdateColors() {
241 ui::NativeTheme::ColorId fg_color_id =
242 is_prominent_ ? ui::NativeTheme::kColorId_TextOnProminentButtonColor
243 : ui::NativeTheme::kColorId_ButtonEnabledColor;
244
245 ui::NativeTheme* theme = GetNativeTheme(); 241 ui::NativeTheme* theme = GetNativeTheme();
242 SkColor enabled_text_color = style::GetColor(
243 label()->text_context(),
244 is_prominent_ ? style::STYLE_DIALOG_BUTTON_DEFAULT : style::STYLE_PRIMARY,
245 theme);
246 if (!explicitly_set_normal_color()) { 246 if (!explicitly_set_normal_color()) {
247 const auto colors = explicitly_set_colors(); 247 const auto colors = explicitly_set_colors();
248 LabelButton::SetEnabledTextColors(theme->GetSystemColor(fg_color_id)); 248 LabelButton::SetEnabledTextColors(enabled_text_color);
249 set_explicitly_set_colors(colors); 249 set_explicitly_set_colors(colors);
250 } 250 }
251 251
252 // Prominent buttons keep their enabled text color; disabled state is conveyed 252 // Prominent buttons keep their enabled text color; disabled state is conveyed
253 // by shading the background instead. 253 // by shading the background instead.
254 if (is_prominent_) 254 if (is_prominent_)
255 SetTextColor(STATE_DISABLED, theme->GetSystemColor(fg_color_id)); 255 SetTextColor(STATE_DISABLED, enabled_text_color);
256 256
257 SkColor text_color = label()->enabled_color(); 257 SkColor text_color = label()->enabled_color();
258 SkColor bg_color = 258 SkColor bg_color =
259 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); 259 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
260 260
261 if (bg_color_override_) { 261 if (bg_color_override_) {
262 bg_color = *bg_color_override_; 262 bg_color = *bg_color_override_;
263 } else if (is_prominent_) { 263 } else if (is_prominent_) {
264 bg_color = theme->GetSystemColor( 264 bg_color = theme->GetSystemColor(
265 ui::NativeTheme::kColorId_ProminentButtonColor); 265 ui::NativeTheme::kColorId_ProminentButtonColor);
(...skipping 24 matching lines...) Expand all
290 } 290 }
291 291
292 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 292 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
293 SetBackground( 293 SetBackground(
294 CreateBackgroundFromPainter(Painter::CreateRoundRectWith1PxBorderPainter( 294 CreateBackgroundFromPainter(Painter::CreateRoundRectWith1PxBorderPainter(
295 bg_color, stroke_color, kInkDropSmallCornerRadius))); 295 bg_color, stroke_color, kInkDropSmallCornerRadius)));
296 SchedulePaint(); 296 SchedulePaint();
297 } 297 }
298 298
299 } // namespace views 299 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/harmony/harmony_typography_provider.cc ('k') | ui/views/controls/label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698