| OLD | NEW |
| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 415 } |
| 416 | 416 |
| 417 void LabelButton::ResetColorsFromNativeTheme() { | 417 void LabelButton::ResetColorsFromNativeTheme() { |
| 418 const ui::NativeTheme* theme = GetNativeTheme(); | 418 const ui::NativeTheme* theme = GetNativeTheme(); |
| 419 bool button_style = style() == STYLE_BUTTON; | 419 bool button_style = style() == STYLE_BUTTON; |
| 420 // Button colors are used only for STYLE_BUTTON, otherwise we use label | 420 // Button colors are used only for STYLE_BUTTON, otherwise we use label |
| 421 // colors. As it turns out, these are almost always the same color anyway in | 421 // colors. As it turns out, these are almost always the same color anyway in |
| 422 // pre-MD, although in the MD world labels and buttons get different colors. | 422 // pre-MD, although in the MD world labels and buttons get different colors. |
| 423 // TODO(estade): simplify this by removing STYLE_BUTTON. | 423 // TODO(estade): simplify this by removing STYLE_BUTTON. |
| 424 SkColor colors[STATE_COUNT] = { | 424 SkColor colors[STATE_COUNT] = { |
| 425 theme->GetSystemColor(button_style | 425 theme->GetSystemColor( |
| 426 ? ui::NativeTheme::kColorId_ButtonEnabledColor | 426 button_style ? ui::NativeTheme::kColorId_TextOnEnabledDialogButton |
| 427 : ui::NativeTheme::kColorId_LabelEnabledColor), | 427 : ui::NativeTheme::kColorId_LabelEnabledColor), |
| 428 theme->GetSystemColor(button_style | 428 theme->GetSystemColor(button_style |
| 429 ? ui::NativeTheme::kColorId_ButtonHoverColor | 429 ? ui::NativeTheme::kColorId_ButtonHoverColor |
| 430 : ui::NativeTheme::kColorId_LabelEnabledColor), | 430 : ui::NativeTheme::kColorId_LabelEnabledColor), |
| 431 theme->GetSystemColor(button_style | 431 theme->GetSystemColor(button_style |
| 432 ? ui::NativeTheme::kColorId_ButtonHoverColor | 432 ? ui::NativeTheme::kColorId_ButtonHoverColor |
| 433 : ui::NativeTheme::kColorId_LabelEnabledColor), | 433 : ui::NativeTheme::kColorId_LabelEnabledColor), |
| 434 theme->GetSystemColor(button_style | 434 theme->GetSystemColor( |
| 435 ? ui::NativeTheme::kColorId_ButtonDisabledColor | 435 button_style ? ui::NativeTheme::kColorId_TextOnDisabledDialogButton |
| 436 : ui::NativeTheme::kColorId_LabelDisabledColor), | 436 : ui::NativeTheme::kColorId_LabelDisabledColor), |
| 437 }; | 437 }; |
| 438 | 438 |
| 439 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON. | 439 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON. |
| 440 if (color_utils::IsInvertedColorScheme()) { | 440 if (color_utils::IsInvertedColorScheme()) { |
| 441 colors[STATE_NORMAL] = colors[STATE_HOVERED] = colors[STATE_PRESSED] = | 441 colors[STATE_NORMAL] = colors[STATE_HOVERED] = colors[STATE_PRESSED] = |
| 442 SK_ColorWHITE; | 442 SK_ColorWHITE; |
| 443 label_->SetBackgroundColor(SK_ColorBLACK); | 443 label_->SetBackgroundColor(SK_ColorBLACK); |
| 444 label_->SetBackground(CreateSolidBackground(SK_ColorBLACK)); | 444 label_->SetBackground(CreateSolidBackground(SK_ColorBLACK)); |
| 445 label_->SetAutoColorReadabilityEnabled(true); | 445 label_->SetAutoColorReadabilityEnabled(true); |
| 446 label_->SetShadows(gfx::ShadowValues()); | 446 label_->SetShadows(gfx::ShadowValues()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 void LabelButton::ResetLabelEnabledColor() { | 545 void LabelButton::ResetLabelEnabledColor() { |
| 546 const SkColor color = | 546 const SkColor color = |
| 547 explicitly_set_colors_[state()] | 547 explicitly_set_colors_[state()] |
| 548 ? button_state_colors_[state()] | 548 ? button_state_colors_[state()] |
| 549 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 549 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 550 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 550 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 551 label_->SetEnabledColor(color); | 551 label_->SetEnabledColor(color); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace views | 554 } // namespace views |
| OLD | NEW |