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

Side by Side Diff: chrome/browser/ui/views/bar_control_button.cc

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt to refactor ink drop animations (wired up chained EventHandler) Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/views/bar_control_button.h" 5 #include "chrome/browser/ui/views/bar_control_button.h"
6 6
7 #include "ui/gfx/color_utils.h" 7 #include "ui/gfx/color_utils.h"
8 #include "ui/gfx/paint_vector_icon.h" 8 #include "ui/gfx/paint_vector_icon.h"
9 #include "ui/gfx/vector_icons_public.h" 9 #include "ui/gfx/vector_icons_public.h"
10 #include "ui/views/animation/ink_drop_animation_controller.h" 10 #include "ui/views/animation/ink_drop_animation_controller.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 SetImage(views::CustomButton::STATE_DISABLED, &image); 59 SetImage(views::CustomButton::STATE_DISABLED, &image);
60 } 60 }
61 61
62 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { 62 void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
63 OnThemeChanged(); 63 OnThemeChanged();
64 } 64 }
65 65
66 void BarControlButton::Layout() { 66 void BarControlButton::Layout() {
67 ImageButton::Layout(); 67 ImageButton::Layout();
68 68
69 ink_drop_animation_controller_->SetInkDropCenter( 69 ink_drop_animation_controller_->SetInkDropCenter(CalculateInkDropCenter());
70 GetLocalBounds().CenterPoint());
71 } 70 }
72 71
73 void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { 72 void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
74 SetPaintToLayer(true); 73 SetPaintToLayer(true);
75 SetFillsBoundsOpaquely(false); 74 SetFillsBoundsOpaquely(false);
76 layer()->Add(ink_drop_layer); 75 layer()->Add(ink_drop_layer);
77 layer()->StackAtBottom(ink_drop_layer); 76 layer()->StackAtBottom(ink_drop_layer);
78 } 77 }
79 78
80 void BarControlButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 79 void BarControlButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
81 layer()->Remove(ink_drop_layer); 80 layer()->Remove(ink_drop_layer);
82 SetFillsBoundsOpaquely(true); 81 SetFillsBoundsOpaquely(true);
83 SetPaintToLayer(false); 82 SetPaintToLayer(false);
84 } 83 }
85 84
85 gfx::Point BarControlButton::CalculateInkDropCenter() const {
86 return GetLocalBounds().CenterPoint();
87 }
88
86 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) { 89 bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) {
87 if (IsTriggerableEvent(event)) { 90 if (IsTriggerableEvent(event)) {
88 ink_drop_animation_controller_->AnimateToState( 91 ink_drop_animation_controller_->AnimateToState(
89 views::InkDropState::ACTION_PENDING); 92 views::InkDropState::ACTION_PENDING);
90 } 93 }
91 94
92 return ImageButton::OnMousePressed(event); 95 return ImageButton::OnMousePressed(event);
93 } 96 }
94 97
95 void BarControlButton::OnGestureEvent(ui::GestureEvent* event) { 98 void BarControlButton::OnGestureEvent(ui::GestureEvent* event) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 131
129 ImageButton::OnMouseReleased(event); 132 ImageButton::OnMouseReleased(event);
130 } 133 }
131 134
132 void BarControlButton::NotifyClick(const ui::Event& event) { 135 void BarControlButton::NotifyClick(const ui::Event& event) {
133 ink_drop_animation_controller_->AnimateToState( 136 ink_drop_animation_controller_->AnimateToState(
134 views::InkDropState::QUICK_ACTION); 137 views::InkDropState::QUICK_ACTION);
135 138
136 ImageButton::NotifyClick(event); 139 ImageButton::NotifyClick(event);
137 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698