| 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/image_button.h" | 5 #include "ui/views/controls/button/image_button.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 ImageButton::~ImageButton() { | 43 ImageButton::~ImageButton() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 const gfx::ImageSkia& ImageButton::GetImage(ButtonState state) const { | 46 const gfx::ImageSkia& ImageButton::GetImage(ButtonState state) const { |
| 47 return images_[state]; | 47 return images_[state]; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia* image) { | 50 void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia* image) { |
| 51 if (for_state == STATE_HOVERED) |
| 52 set_animate_on_state_change(image != nullptr); |
| 51 images_[for_state] = image ? *image : gfx::ImageSkia(); | 53 images_[for_state] = image ? *image : gfx::ImageSkia(); |
| 52 PreferredSizeChanged(); | 54 PreferredSizeChanged(); |
| 53 if (state() == for_state) | 55 if (state() == for_state) |
| 54 SchedulePaint(); | 56 SchedulePaint(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void ImageButton::SetBackground(SkColor color, | 59 void ImageButton::SetBackground(SkColor color, |
| 58 const gfx::ImageSkia* image, | 60 const gfx::ImageSkia* image, |
| 59 const gfx::ImageSkia* mask) { | 61 const gfx::ImageSkia* mask) { |
| 60 if (image == NULL || mask == NULL) { | 62 if (image == NULL || mask == NULL) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // accessible toggle button. | 277 // accessible toggle button. |
| 276 if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) || | 278 if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) || |
| 277 (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) { | 279 (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) { |
| 278 state->role = ui::AX_ROLE_TOGGLE_BUTTON; | 280 state->role = ui::AX_ROLE_TOGGLE_BUTTON; |
| 279 if (toggled_) | 281 if (toggled_) |
| 280 state->AddStateFlag(ui::AX_STATE_PRESSED); | 282 state->AddStateFlag(ui::AX_STATE_PRESSED); |
| 281 } | 283 } |
| 282 } | 284 } |
| 283 | 285 |
| 284 } // namespace views | 286 } // namespace views |
| OLD | NEW |