Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: ui/views/controls/button/toggle_button.cc

Issue 2396133005: [ash-md] Animates ToggleButton highlight to move it in sync with the thumb (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/toggle_button.cc
diff --git a/ui/views/controls/button/toggle_button.cc b/ui/views/controls/button/toggle_button.cc
index 30bf562a54887ce6a3b62c24af0408b80104c884..e382b4083e7c7b0b196b181f516c3224755f297b 100644
--- a/ui/views/controls/button/toggle_button.cc
+++ b/ui/views/controls/button/toggle_button.cc
@@ -99,6 +99,9 @@ void ToggleButton::OnPaint(gfx::Canvas* canvas) {
color_utils::AlphaBlend(thumb_on_color, thumb_off_color, blend));
canvas->DrawCircle(gfx::RectF(thumb_bounds).CenterPoint(),
thumb_bounds.height() / 2.f, thumb_paint);
+
+ // Adjust thumb ink drop highlight position to make it animate with the thumb.
+ OffsetInkDropRipple(thumb_bounds.CenterPoint() - original_center_point_);
Evan Stade 2016/10/10 17:33:15 I'm kind of skeptical this will look great/stay in
varkha 2016/10/12 00:44:59 Done.
}
void ToggleButton::NotifyClick(const ui::Event& event) {
@@ -110,6 +113,11 @@ void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
SchedulePaint();
}
+void ToggleButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
+ original_center_point_ = GetThumbBounds().CenterPoint();
+ CustomButton::AddInkDropLayer(ink_drop_layer);
+}
+
std::unique_ptr<InkDropRipple> ToggleButton::CreateInkDropRipple() const {
return CreateDefaultInkDropRipple(GetThumbBounds().CenterPoint());
}
« ui/views/animation/ink_drop_host.h ('K') | « ui/views/controls/button/toggle_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698