| Index: ui/views/controls/button/label_button.cc
|
| diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
|
| index bc1c06351ee9ed514c0c2f62b20c4e6cec259a59..3e234cb4086de50fe92262e03f97f95de4a41065 100644
|
| --- a/ui/views/controls/button/label_button.cc
|
| +++ b/ui/views/controls/button/label_button.cc
|
| @@ -61,13 +61,21 @@ LabelButton::LabelButton(ButtonListener* listener, const string16& text)
|
| LabelButton::~LabelButton() {}
|
|
|
| const gfx::ImageSkia& LabelButton::GetImage(ButtonState for_state) {
|
| - if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull())
|
| - return button_state_images_[STATE_NORMAL];
|
| - return button_state_images_[for_state];
|
| + const size_t focused_index = HasFocus() ? 1 : 0;
|
| + if (for_state != STATE_NORMAL &&
|
| + button_state_images_[focused_index][for_state].isNull())
|
| + return button_state_images_[focused_index][STATE_NORMAL];
|
| + return button_state_images_[focused_index][for_state];
|
| }
|
|
|
| void LabelButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) {
|
| - button_state_images_[for_state] = image;
|
| + button_state_images_[0][for_state] = image;
|
| + image_->SetImage(GetImage(state()));
|
| +}
|
| +
|
| +void LabelButton::SetFocusedImage(ButtonState for_state,
|
| + const gfx::ImageSkia& image) {
|
| + button_state_images_[1][for_state] = image;
|
| image_->SetImage(GetImage(state()));
|
| }
|
|
|
| @@ -194,6 +202,17 @@ const char* LabelButton::GetClassName() const {
|
| return kViewClassName;
|
| }
|
|
|
| +void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
|
| + params->button.checked = false;
|
| + params->button.indeterminate = false;
|
| + params->button.is_default = is_default_;
|
| + params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
|
| + params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
|
| + params->button.classic_state = 0;
|
| + params->button.background_color = GetNativeTheme()->GetSystemColor(
|
| + ui::NativeTheme::kColorId_ButtonBackgroundColor);
|
| +}
|
| +
|
| void LabelButton::ResetColorsFromNativeTheme() {
|
| const ui::NativeTheme* theme = GetNativeTheme();
|
| SkColor colors[STATE_COUNT] = {
|
| @@ -292,7 +311,7 @@ gfx::Rect LabelButton::GetThemePaintRect() const {
|
| ui::NativeTheme::State LabelButton::GetThemeState(
|
| ui::NativeTheme::ExtraParams* params) const {
|
| GetExtraParams(params);
|
| - switch(state()) {
|
| + switch (state()) {
|
| case STATE_NORMAL: return ui::NativeTheme::kNormal;
|
| case STATE_HOVERED: return ui::NativeTheme::kHovered;
|
| case STATE_PRESSED: return ui::NativeTheme::kPressed;
|
| @@ -325,15 +344,4 @@ ui::NativeTheme::State LabelButton::GetForegroundThemeState(
|
| return ui::NativeTheme::kHovered;
|
| }
|
|
|
| -void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
|
| - params->button.checked = false;
|
| - params->button.indeterminate = false;
|
| - params->button.is_default = is_default_;
|
| - params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
|
| - params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
|
| - params->button.classic_state = 0;
|
| - params->button.background_color = GetNativeTheme()->GetSystemColor(
|
| - ui::NativeTheme::kColorId_ButtonBackgroundColor);
|
| -}
|
| -
|
| } // namespace views
|
|
|