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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // static | 100 // static |
101 const char ToggleButton::kViewClassName[] = "ToggleButton"; | 101 const char ToggleButton::kViewClassName[] = "ToggleButton"; |
102 | 102 |
103 ToggleButton::ToggleButton(ButtonListener* listener) | 103 ToggleButton::ToggleButton(ButtonListener* listener) |
104 : CustomButton(listener), | 104 : CustomButton(listener), |
105 is_on_(false), | 105 is_on_(false), |
106 slide_animation_(this), | 106 slide_animation_(this), |
107 thumb_view_(new ThumbView()) { | 107 thumb_view_(new ThumbView()) { |
108 slide_animation_.SetSlideDuration(80 /* ms */); | 108 slide_animation_.SetSlideDuration(80 /* ms */); |
109 slide_animation_.SetTweenType(gfx::Tween::LINEAR); | 109 slide_animation_.SetTweenType(gfx::Tween::LINEAR); |
110 SetBorder(Border::CreateEmptyBorder( | 110 SetBorder(CreateEmptyBorder( |
111 gfx::Insets(kTrackVerticalMargin, kTrackHorizontalMargin))); | 111 gfx::Insets(kTrackVerticalMargin, kTrackHorizontalMargin))); |
112 AddChildView(thumb_view_); | 112 AddChildView(thumb_view_); |
113 SetInkDropMode(InkDropMode::ON); | 113 SetInkDropMode(InkDropMode::ON); |
114 set_has_ink_drop_action_on_click(true); | 114 set_has_ink_drop_action_on_click(true); |
115 } | 115 } |
116 | 116 |
117 ToggleButton::~ToggleButton() { | 117 ToggleButton::~ToggleButton() { |
118 // Destroying ink drop early allows ink drop layer to be properly removed, | 118 // Destroying ink drop early allows ink drop layer to be properly removed, |
119 SetInkDropMode(InkDropMode::OFF); | 119 SetInkDropMode(InkDropMode::OFF); |
120 } | 120 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // 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 |
238 // repainting in every animation step to update colors could be avoided. | 238 // repainting in every animation step to update colors could be avoided. |
239 UpdateThumb(); | 239 UpdateThumb(); |
240 SchedulePaint(); | 240 SchedulePaint(); |
241 return; | 241 return; |
242 } | 242 } |
243 CustomButton::AnimationProgressed(animation); | 243 CustomButton::AnimationProgressed(animation); |
244 } | 244 } |
245 | 245 |
246 } // namespace views | 246 } // namespace views |
OLD | NEW |