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

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

Issue 2240603002: Harmony checkbox/radio tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests 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/checkbox.cc ('k') | ui/views/controls/button/label_button_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 params->button.indeterminate = false; 478 params->button.indeterminate = false;
479 params->button.is_default = is_default_; 479 params->button.is_default = is_default_;
480 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); 480 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
481 params->button.has_border = false; 481 params->button.has_border = false;
482 params->button.classic_state = 0; 482 params->button.classic_state = 0;
483 params->button.background_color = label_->background_color(); 483 params->button.background_color = label_->background_color();
484 } 484 }
485 485
486 void LabelButton::ResetColorsFromNativeTheme() { 486 void LabelButton::ResetColorsFromNativeTheme() {
487 const ui::NativeTheme* theme = GetNativeTheme(); 487 const ui::NativeTheme* theme = GetNativeTheme();
488 bool button_style = style() == STYLE_BUTTON;
489 // Button colors are used only for STYLE_BUTTON, otherwise we use label
490 // colors. As it turns out, these are almost always the same color anyway in
491 // pre-MD, although in the MD world labels and buttons get different colors.
492 // TODO(estade): simplify this by removing STYLE_BUTTON.
488 SkColor colors[STATE_COUNT] = { 493 SkColor colors[STATE_COUNT] = {
489 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), 494 theme->GetSystemColor(button_style
490 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 495 ? ui::NativeTheme::kColorId_ButtonEnabledColor
491 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 496 : ui::NativeTheme::kColorId_LabelEnabledColor),
492 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), 497 theme->GetSystemColor(button_style
498 ? ui::NativeTheme::kColorId_ButtonHoverColor
499 : ui::NativeTheme::kColorId_LabelEnabledColor),
500 theme->GetSystemColor(button_style
501 ? ui::NativeTheme::kColorId_ButtonHoverColor
502 : ui::NativeTheme::kColorId_LabelEnabledColor),
503 theme->GetSystemColor(button_style
504 ? ui::NativeTheme::kColorId_ButtonDisabledColor
505 : ui::NativeTheme::kColorId_LabelDisabledColor),
493 }; 506 };
494 507
495 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON. 508 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON.
496 if (color_utils::IsInvertedColorScheme()) { 509 if (color_utils::IsInvertedColorScheme()) {
497 colors[STATE_NORMAL] = colors[STATE_HOVERED] = colors[STATE_PRESSED] = 510 colors[STATE_NORMAL] = colors[STATE_HOVERED] = colors[STATE_PRESSED] =
498 SK_ColorWHITE; 511 SK_ColorWHITE;
499 label_->SetBackgroundColor(SK_ColorBLACK); 512 label_->SetBackgroundColor(SK_ColorBLACK);
500 label_->set_background(Background::CreateSolidBackground(SK_ColorBLACK)); 513 label_->set_background(Background::CreateSolidBackground(SK_ColorBLACK));
501 label_->SetAutoColorReadabilityEnabled(true); 514 label_->SetAutoColorReadabilityEnabled(true);
502 label_->SetShadows(gfx::ShadowValues()); 515 label_->SetShadows(gfx::ShadowValues());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 void LabelButton::ResetLabelEnabledColor() { 606 void LabelButton::ResetLabelEnabledColor() {
594 const SkColor color = 607 const SkColor color =
595 explicitly_set_colors_[state()] 608 explicitly_set_colors_[state()]
596 ? button_state_colors_[state()] 609 ? button_state_colors_[state()]
597 : PlatformStyle::TextColorForButton(button_state_colors_, *this); 610 : PlatformStyle::TextColorForButton(button_state_colors_, *this);
598 if (state() != STATE_DISABLED && label_->enabled_color() != color) 611 if (state() != STATE_DISABLED && label_->enabled_color() != color)
599 label_->SetEnabledColor(color); 612 label_->SetEnabledColor(color);
600 } 613 }
601 614
602 } // namespace views 615 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/label_button_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698