| 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 29 matching lines...) Expand all Loading... |
| 40 EnableCanvasFlippingForRTLUI(true); | 40 EnableCanvasFlippingForRTLUI(true); |
| 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 state, const gfx::ImageSkia* image) { | 50 void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia* image) { |
| 51 images_[state] = image ? *image : gfx::ImageSkia(); | 51 images_[for_state] = image ? *image : gfx::ImageSkia(); |
| 52 PreferredSizeChanged(); | 52 PreferredSizeChanged(); |
| 53 if (state() == for_state) |
| 54 SchedulePaint(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void ImageButton::SetBackground(SkColor color, | 57 void ImageButton::SetBackground(SkColor color, |
| 56 const gfx::ImageSkia* image, | 58 const gfx::ImageSkia* image, |
| 57 const gfx::ImageSkia* mask) { | 59 const gfx::ImageSkia* mask) { |
| 58 if (image == NULL || mask == NULL) { | 60 if (image == NULL || mask == NULL) { |
| 59 background_image_ = gfx::ImageSkia(); | 61 background_image_ = gfx::ImageSkia(); |
| 60 return; | 62 return; |
| 61 } | 63 } |
| 62 | 64 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 *tooltip = toggled_tooltip_text_; | 266 *tooltip = toggled_tooltip_text_; |
| 265 return true; | 267 return true; |
| 266 } | 268 } |
| 267 | 269 |
| 268 void ToggleImageButton::GetAccessibleState(ui::AXViewState* state) { | 270 void ToggleImageButton::GetAccessibleState(ui::AXViewState* state) { |
| 269 ImageButton::GetAccessibleState(state); | 271 ImageButton::GetAccessibleState(state); |
| 270 GetTooltipText(gfx::Point(), &state->name); | 272 GetTooltipText(gfx::Point(), &state->name); |
| 271 } | 273 } |
| 272 | 274 |
| 273 } // namespace views | 275 } // namespace views |
| OLD | NEW |