Index: chrome/browser/ui/views/toolbar/toolbar_button.cc |
diff --git a/chrome/browser/ui/views/toolbar/toolbar_button.cc b/chrome/browser/ui/views/toolbar/toolbar_button.cc |
index 03bf129c996ce1377060ae586997e0aaa88a0389..b0242cfe615b7451ebff957c9e00424bd5fcd6d3 100644 |
--- a/chrome/browser/ui/views/toolbar/toolbar_button.cc |
+++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc |
@@ -18,8 +18,7 @@ |
#include "ui/gfx/display.h" |
#include "ui/gfx/screen.h" |
#include "ui/strings/grit/ui_strings.h" |
-#include "ui/views/animation/ink_drop_animation_controller.h" |
-#include "ui/views/animation/ink_drop_animation_controller_factory.h" |
+#include "ui/views/animation/button_ink_drop_delegate.h" |
#include "ui/views/controls/button/label_button_border.h" |
#include "ui/views/controls/menu/menu_item_view.h" |
#include "ui/views/controls/menu/menu_model_adapter.h" |
@@ -32,10 +31,10 @@ ToolbarButton::ToolbarButton(views::ButtonListener* listener, |
model_(model), |
menu_showing_(false), |
y_position_on_lbuttondown_(0), |
- ink_drop_animation_controller_( |
- views::InkDropAnimationControllerFactory:: |
- CreateInkDropAnimationController(this)), |
show_menu_factory_(this) { |
+ scoped_ptr<views::InkDropDelegate> new_ink_drop_delegate( |
+ new views::ButtonInkDropDelegate(this, this)); |
+ SetInkDropDelegate(new_ink_drop_delegate.Pass()); |
set_context_menu_controller(this); |
const int kInkDropLargeSize = 32; |
@@ -43,10 +42,8 @@ ToolbarButton::ToolbarButton(views::ButtonListener* listener, |
const int kInkDropSmallSize = 24; |
const int kInkDropSmallCornerRadius = 2; |
- ink_drop_animation_controller_->SetInkDropSize( |
- gfx::Size(kInkDropLargeSize, kInkDropLargeSize), |
- kInkDropLargeCornerRadius, |
- gfx::Size(kInkDropSmallSize, kInkDropSmallSize), |
+ ink_drop_delegate()->SetInkDropSize( |
+ kInkDropLargeSize, kInkDropLargeCornerRadius, kInkDropSmallSize, |
kInkDropSmallCornerRadius); |
} |
@@ -88,11 +85,6 @@ gfx::Size ToolbarButton::GetPreferredSize() const { |
return size; |
} |
-void ToolbarButton::Layout() { |
- LabelButton::Layout(); |
- ink_drop_animation_controller_->SetInkDropCenter(CalculateInkDropCenter()); |
-} |
- |
bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { |
if (IsTriggerableEvent(event)) { |
varkha
2015/12/07 19:24:47
nit: Can roll all the conditions together now that
bruthig
2015/12/07 19:39:03
Done.
|
if (enabled() && ShouldShowMenu() && HitTestPoint(event.location())) { |
@@ -109,8 +101,6 @@ bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { |
ui::GetMenuSourceTypeForEvent(event)), |
base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); |
} |
- ink_drop_animation_controller_->AnimateToState( |
- views::InkDropState::ACTION_PENDING); |
} |
return LabelButton::OnMousePressed(event); |
@@ -161,32 +151,6 @@ void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
} |
LabelButton::OnGestureEvent(event); |
- |
- views::InkDropState ink_drop_state = views::InkDropState::HIDDEN; |
- switch (event->type()) { |
- case ui::ET_GESTURE_TAP_DOWN: |
- ink_drop_state = views::InkDropState::ACTION_PENDING; |
- // The ui::ET_GESTURE_TAP_DOWN event needs to be marked as handled so that |
- // subsequent events for the gesture are sent to |this|. |
- event->SetHandled(); |
- break; |
- case ui::ET_GESTURE_LONG_PRESS: |
- ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING; |
- break; |
- case ui::ET_GESTURE_TAP: |
- ink_drop_state = views::InkDropState::QUICK_ACTION; |
- break; |
- case ui::ET_GESTURE_LONG_TAP: |
- ink_drop_state = views::InkDropState::SLOW_ACTION; |
- break; |
- case ui::ET_GESTURE_END: |
- case ui::ET_GESTURE_TAP_CANCEL: |
- ink_drop_state = views::InkDropState::HIDDEN; |
- break; |
- default: |
- return; |
- } |
- ink_drop_animation_controller_->AnimateToState(ink_drop_state); |
} |
void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { |
@@ -249,17 +213,6 @@ bool ToolbarButton::ShouldEnterPushedState(const ui::Event& event) { |
ui::EF_RIGHT_MOUSE_BUTTON) & event.flags()) != 0); |
} |
-void ToolbarButton::NotifyClick(const ui::Event& event) { |
- LabelButton::NotifyClick(event); |
- ink_drop_animation_controller_->AnimateToState( |
- views::InkDropState::QUICK_ACTION); |
-} |
- |
-void ToolbarButton::OnClickCanceled(const ui::Event& event) { |
- LabelButton::OnClickCanceled(event); |
- ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); |
-} |
- |
bool ToolbarButton::ShouldShowMenu() { |
return model_ != nullptr; |
} |
@@ -306,8 +259,7 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { |
menu_showing_ = true; |
- ink_drop_animation_controller_->AnimateToState( |
- views::InkDropState::ACTIVATED); |
+ ink_drop_delegate()->OnAction(views::InkDropState::ACTIVATED); |
// Create and run menu. Display an empty menu if model is NULL. |
views::MenuRunner::RunResult result; |
@@ -331,8 +283,7 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { |
if (result == views::MenuRunner::MENU_DELETED) |
return; |
- ink_drop_animation_controller_->AnimateToState( |
- views::InkDropState::DEACTIVATED); |
+ ink_drop_delegate()->OnAction(views::InkDropState::DEACTIVATED); |
menu_showing_ = false; |