| 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/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/color_palette.h" | 10 #include "ui/gfx/color_palette.h" |
| 11 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/views/animation/ink_drop_impl.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 |
| 19 // Constants are measured in dip. | 20 // Constants are measured in dip. |
| 20 const int kTrackHeight = 12; | 21 const int kTrackHeight = 12; |
| 21 const int kTrackWidth = 28; | 22 const int kTrackWidth = 28; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return CreateDefaultInkDropRipple(gfx::Point(radius, radius)); | 205 return CreateDefaultInkDropRipple(gfx::Point(radius, radius)); |
| 205 } | 206 } |
| 206 | 207 |
| 207 SkColor ToggleButton::GetInkDropBaseColor() const { | 208 SkColor ToggleButton::GetInkDropBaseColor() const { |
| 208 return is_on() | 209 return is_on() |
| 209 ? GetNativeTheme()->GetSystemColor( | 210 ? GetNativeTheme()->GetSystemColor( |
| 210 ui::NativeTheme::kColorId_ProminentButtonColor) | 211 ui::NativeTheme::kColorId_ProminentButtonColor) |
| 211 : kTrackOffColor; | 212 : kTrackOffColor; |
| 212 } | 213 } |
| 213 | 214 |
| 214 bool ToggleButton::ShouldShowInkDropHighlight() const { | 215 std::unique_ptr<InkDrop> ToggleButton::CreateInkDrop() { |
| 215 return false; | 216 std::unique_ptr<InkDropImpl> ink_drop = |
| 217 CustomButton::CreateDefaultInkDropImpl(); |
| 218 ink_drop->SetShowHighlightOnHover(false); |
| 219 return std::move(ink_drop); |
| 216 } | 220 } |
| 217 | 221 |
| 218 void ToggleButton::AnimationProgressed(const gfx::Animation* animation) { | 222 void ToggleButton::AnimationProgressed(const gfx::Animation* animation) { |
| 219 if (animation == &slide_animation_) { | 223 if (animation == &slide_animation_) { |
| 220 // TODO(varkha, estade): The thumb is using its own view. Investigate if | 224 // TODO(varkha, estade): The thumb is using its own view. Investigate if |
| 221 // repainting in every animation step to update colors could be avoided. | 225 // repainting in every animation step to update colors could be avoided. |
| 222 UpdateThumb(); | 226 UpdateThumb(); |
| 223 SchedulePaint(); | 227 SchedulePaint(); |
| 224 return; | 228 return; |
| 225 } | 229 } |
| 226 CustomButton::AnimationProgressed(animation); | 230 CustomButton::AnimationProgressed(animation); |
| 227 } | 231 } |
| 228 | 232 |
| 229 } // namespace views | 233 } // namespace views |
| OLD | NEW |