| 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_node_data.h" |
| 11 #include "ui/gfx/animation/throb_animation.h" | 11 #include "ui/gfx/animation/throb_animation.h" |
| 12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/image/image_skia_operations.h" | 13 #include "ui/gfx/image/image_skia_operations.h" |
| 14 #include "ui/gfx/scoped_canvas.h" | 14 #include "ui/gfx/scoped_canvas.h" |
| 15 #include "ui/views/painter.h" | 15 #include "ui/views/painter.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 // Default button size if no image is set. This is ignored if there is an image, | 20 // Default button size if no image is set. This is ignored if there is an image, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, | 263 bool ToggleImageButton::GetTooltipText(const gfx::Point& p, |
| 264 base::string16* tooltip) const { | 264 base::string16* tooltip) const { |
| 265 if (!toggled_ || toggled_tooltip_text_.empty()) | 265 if (!toggled_ || toggled_tooltip_text_.empty()) |
| 266 return Button::GetTooltipText(p, tooltip); | 266 return Button::GetTooltipText(p, tooltip); |
| 267 | 267 |
| 268 *tooltip = toggled_tooltip_text_; | 268 *tooltip = toggled_tooltip_text_; |
| 269 return true; | 269 return true; |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ToggleImageButton::GetAccessibleState(ui::AXViewState* state) { | 272 void ToggleImageButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 273 ImageButton::GetAccessibleState(state); | 273 ImageButton::GetAccessibleNodeData(node_data); |
| 274 GetTooltipText(gfx::Point(), &state->name); | 274 base::string16 name; |
| 275 GetTooltipText(gfx::Point(), &name); |
| 276 node_data->SetName(name); |
| 275 | 277 |
| 276 // Use the visual pressed image as a cue for making this control into an | 278 // Use the visual pressed image as a cue for making this control into an |
| 277 // accessible toggle button. | 279 // accessible toggle button. |
| 278 if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) || | 280 if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) || |
| 279 (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) { | 281 (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) { |
| 280 state->role = ui::AX_ROLE_TOGGLE_BUTTON; | 282 node_data->role = ui::AX_ROLE_TOGGLE_BUTTON; |
| 281 if (toggled_) | 283 if (toggled_) |
| 282 state->AddStateFlag(ui::AX_STATE_PRESSED); | 284 node_data->AddStateFlag(ui::AX_STATE_PRESSED); |
| 283 } | 285 } |
| 284 } | 286 } |
| 285 | 287 |
| 286 } // namespace views | 288 } // namespace views |
| OLD | NEW |