| 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/accessibility/ax_node_data.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/color_palette.h" | 11 #include "ui/gfx/color_palette.h" |
| 12 #include "ui/gfx/color_utils.h" | 12 #include "ui/gfx/color_utils.h" |
| 13 #include "ui/views/animation/ink_drop_impl.h" |
| 13 #include "ui/views/animation/ink_drop_ripple.h" | 14 #include "ui/views/animation/ink_drop_ripple.h" |
| 14 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
| 15 | 16 |
| 16 namespace views { | 17 namespace views { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // Constants are measured in dip. | 21 // Constants are measured in dip. |
| 21 const int kTrackHeight = 12; | 22 const int kTrackHeight = 12; |
| 22 const int kTrackWidth = 28; | 23 const int kTrackWidth = 28; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 212 } |
| 212 | 213 |
| 213 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 214 void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 214 thumb_view_->AddInkDropLayer(ink_drop_layer); | 215 thumb_view_->AddInkDropLayer(ink_drop_layer); |
| 215 } | 216 } |
| 216 | 217 |
| 217 void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 218 void ToggleButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 218 thumb_view_->RemoveInkDropLayer(ink_drop_layer); | 219 thumb_view_->RemoveInkDropLayer(ink_drop_layer); |
| 219 } | 220 } |
| 220 | 221 |
| 222 std::unique_ptr<InkDrop> ToggleButton::CreateInkDrop() { |
| 223 std::unique_ptr<InkDropImpl> ink_drop = |
| 224 CustomButton::CreateDefaultInkDropImpl(); |
| 225 ink_drop->SetShowHighlightOnHover(false); |
| 226 return std::move(ink_drop); |
| 227 } |
| 228 |
| 221 std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const { | 229 std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const { |
| 222 gfx::Rect rect = thumb_view_->GetLocalBounds(); | 230 gfx::Rect rect = thumb_view_->GetLocalBounds(); |
| 223 rect.Inset(-ThumbView::GetShadowOutsets()); | 231 rect.Inset(-ThumbView::GetShadowOutsets()); |
| 224 return CreateDefaultInkDropRipple(rect.CenterPoint()); | 232 return CreateDefaultInkDropRipple(rect.CenterPoint()); |
| 225 } | 233 } |
| 226 | 234 |
| 227 SkColor ToggleButton::GetInkDropBaseColor() const { | 235 SkColor ToggleButton::GetInkDropBaseColor() const { |
| 228 return GetTrackColor(is_on()); | 236 return GetTrackColor(is_on()); |
| 229 } | 237 } |
| 230 | 238 |
| 231 bool ToggleButton::ShouldShowInkDropHighlight() const { | |
| 232 return false; | |
| 233 } | |
| 234 | |
| 235 void ToggleButton::AnimationProgressed(const gfx::Animation* animation) { | 239 void ToggleButton::AnimationProgressed(const gfx::Animation* animation) { |
| 236 if (animation == &slide_animation_) { | 240 if (animation == &slide_animation_) { |
| 237 // TODO(varkha, estade): The thumb is using its own view. Investigate if | 241 // TODO(varkha, estade): The thumb is using its own view. Investigate if |
| 238 // repainting in every animation step to update colors could be avoided. | 242 // repainting in every animation step to update colors could be avoided. |
| 239 UpdateThumb(); | 243 UpdateThumb(); |
| 240 SchedulePaint(); | 244 SchedulePaint(); |
| 241 return; | 245 return; |
| 242 } | 246 } |
| 243 CustomButton::AnimationProgressed(animation); | 247 CustomButton::AnimationProgressed(animation); |
| 244 } | 248 } |
| 245 | 249 |
| 246 } // namespace views | 250 } // namespace views |
| OLD | NEW |