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

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 1478303003: Converted all Views to use an InkDropDelegate instead of a InkDropAnimationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed CustomButton::set_ink_drop_action_on_click() method. Created 5 years 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.h ('k') | ui/views/animation/button_ink_drop_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 808e450ab02544f0e0ca7a8870b5297cc3cfd350..5822bd98f6489cfbbc5b86f4562621f8bc353ae5 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_button.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc
@@ -21,8 +21,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"
@@ -37,26 +36,22 @@ ToolbarButton::ToolbarButton(Profile* profile,
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() {
-}
+ToolbarButton::~ToolbarButton() {}
void ToolbarButton::Init() {
SetFocusable(false);
@@ -93,29 +88,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);
@@ -166,32 +153,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) {
@@ -253,17 +214,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;
}
@@ -310,8 +260,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;
@@ -335,8 +284,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;
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.h ('k') | ui/views/animation/button_ink_drop_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698