| 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
| 9 #include "ui/base/animation/throb_animation.h" | 9 #include "ui/base/animation/throb_animation.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 for (int i = 0; i < STATE_COUNT; ++i) { | 160 for (int i = 0; i < STATE_COUNT; ++i) { |
| 161 gfx::ImageSkia temp = images_[i]; | 161 gfx::ImageSkia temp = images_[i]; |
| 162 images_[i] = alternate_images_[i]; | 162 images_[i] = alternate_images_[i]; |
| 163 alternate_images_[i] = temp; | 163 alternate_images_[i] = temp; |
| 164 } | 164 } |
| 165 toggled_ = toggled; | 165 toggled_ = toggled; |
| 166 SchedulePaint(); | 166 SchedulePaint(); |
| 167 | 167 |
| 168 GetWidget()->NotifyAccessibilityEvent( | 168 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true); |
| 169 this, ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true); | |
| 170 } | 169 } |
| 171 | 170 |
| 172 void ToggleImageButton::SetToggledImage(ButtonState state, | 171 void ToggleImageButton::SetToggledImage(ButtonState state, |
| 173 const gfx::ImageSkia* image) { | 172 const gfx::ImageSkia* image) { |
| 174 if (toggled_) { | 173 if (toggled_) { |
| 175 images_[state] = image ? *image : gfx::ImageSkia(); | 174 images_[state] = image ? *image : gfx::ImageSkia(); |
| 176 if (state_ == state) | 175 if (state_ == state) |
| 177 SchedulePaint(); | 176 SchedulePaint(); |
| 178 } else { | 177 } else { |
| 179 alternate_images_[state] = image ? *image : gfx::ImageSkia(); | 178 alternate_images_[state] = image ? *image : gfx::ImageSkia(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 *tooltip = toggled_tooltip_text_; | 215 *tooltip = toggled_tooltip_text_; |
| 217 return true; | 216 return true; |
| 218 } | 217 } |
| 219 | 218 |
| 220 void ToggleImageButton::GetAccessibleState(ui::AccessibleViewState* state) { | 219 void ToggleImageButton::GetAccessibleState(ui::AccessibleViewState* state) { |
| 221 ImageButton::GetAccessibleState(state); | 220 ImageButton::GetAccessibleState(state); |
| 222 GetTooltipText(gfx::Point(), &state->name); | 221 GetTooltipText(gfx::Point(), &state->name); |
| 223 } | 222 } |
| 224 | 223 |
| 225 } // namespace views | 224 } // namespace views |
| OLD | NEW |