| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/toggle_button.h" | 5 #include "ui/views/controls/button/toggle_button.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkDrawLooper.h" | 7 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
| 9 #include "ui/accessibility/ax_node_data.h" |
| 9 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/color_palette.h" | 11 #include "ui/gfx/color_palette.h" |
| 11 #include "ui/gfx/color_utils.h" | 12 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/views/animation/ink_drop_ripple.h" | 13 #include "ui/views/animation/ink_drop_ripple.h" |
| 13 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 195 } |
| 195 | 196 |
| 196 void ToggleButton::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 197 void ToggleButton::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 197 UpdateThumb(); | 198 UpdateThumb(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 201 void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 201 SchedulePaint(); | 202 SchedulePaint(); |
| 202 } | 203 } |
| 203 | 204 |
| 205 void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 206 CustomButton::GetAccessibleNodeData(node_data); |
| 207 |
| 208 node_data->role = ui::AX_ROLE_SWITCH; |
| 209 if (is_on_) |
| 210 node_data->AddStateFlag(ui::AX_STATE_CHECKED); |
| 211 } |
| 212 |
| 204 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 213 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 205 thumb_view_->AddInkDropLayer(ink_drop_layer); | 214 thumb_view_->AddInkDropLayer(ink_drop_layer); |
| 206 } | 215 } |
| 207 | 216 |
| 208 void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 217 void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 209 thumb_view_->RemoveInkDropLayer(ink_drop_layer); | 218 thumb_view_->RemoveInkDropLayer(ink_drop_layer); |
| 210 } | 219 } |
| 211 | 220 |
| 212 std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const { | 221 std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const { |
| 213 gfx::Rect rect = thumb_view_->GetLocalBounds(); | 222 gfx::Rect rect = thumb_view_->GetLocalBounds(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 228 // TODO(varkha, estade): The thumb is using its own view. Investigate if | 237 // TODO(varkha, estade): The thumb is using its own view. Investigate if |
| 229 // repainting in every animation step to update colors could be avoided. | 238 // repainting in every animation step to update colors could be avoided. |
| 230 UpdateThumb(); | 239 UpdateThumb(); |
| 231 SchedulePaint(); | 240 SchedulePaint(); |
| 232 return; | 241 return; |
| 233 } | 242 } |
| 234 CustomButton::AnimationProgressed(animation); | 243 CustomButton::AnimationProgressed(animation); |
| 235 } | 244 } |
| 236 | 245 |
| 237 } // namespace views | 246 } // namespace views |
| OLD | NEW |