| 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 65788cceac4d12efd221e1fa3704a7c4693a28db..db434686b672aacadf9aec76a988ead4e932226a 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,25 +31,24 @@ ToolbarButton::ToolbarButton(views::ButtonListener* listener,
|
| model_(model),
|
| menu_showing_(false),
|
| y_position_on_lbuttondown_(0),
|
| - ink_drop_animation_controller_(
|
| - views::InkDropAnimationControllerFactory::
|
| - CreateInkDropAnimationController(this)),
|
| + ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)),
|
| show_menu_factory_(this) {
|
| + set_ink_drop_delegate(ink_drop_delegate_.get());
|
| + set_has_ink_drop_action_on_click(true);
|
| set_context_menu_controller(this);
|
|
|
| const int kInkDropLargeSize = 32;
|
| const int kInkDropLargeCornerRadius = 5;
|
| 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);
|
| }
|
|
|
| ToolbarButton::~ToolbarButton() {
|
| + set_ink_drop_delegate(nullptr);
|
| + ink_drop_delegate_.reset();
|
| }
|
|
|
| void ToolbarButton::Init() {
|
| @@ -88,29 +86,21 @@ 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)) {
|
| - if (enabled() && ShouldShowMenu() && HitTestPoint(event.location())) {
|
| - // Store the y pos of the mouse coordinates so we can use them later to
|
| - // determine if the user dragged the mouse down (which should pop up the
|
| - // drag down menu immediately, instead of waiting for the timer)
|
| - y_position_on_lbuttondown_ = event.y();
|
| -
|
| - // Schedule a task that will show the menu.
|
| - const int kMenuTimerDelay = 500;
|
| - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| - FROM_HERE, base::Bind(&ToolbarButton::ShowDropDownMenu,
|
| - show_menu_factory_.GetWeakPtr(),
|
| - ui::GetMenuSourceTypeForEvent(event)),
|
| - base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
|
| - }
|
| - ink_drop_animation_controller_->AnimateToState(
|
| - views::InkDropState::ACTION_PENDING);
|
| + if (IsTriggerableEvent(event) && enabled() && ShouldShowMenu() &&
|
| + HitTestPoint(event.location())) {
|
| + // Store the y pos of the mouse coordinates so we can use them later to
|
| + // determine if the user dragged the mouse down (which should pop up the
|
| + // drag down menu immediately, instead of waiting for the timer)
|
| + y_position_on_lbuttondown_ = event.y();
|
| +
|
| + // Schedule a task that will show the menu.
|
| + const int kMenuTimerDelay = 500;
|
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| + FROM_HERE, base::Bind(&ToolbarButton::ShowDropDownMenu,
|
| + show_menu_factory_.GetWeakPtr(),
|
| + ui::GetMenuSourceTypeForEvent(event)),
|
| + base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
|
| }
|
|
|
| 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;
|
|
|
|
|