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

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: Fixed compile errors 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 side-by-side diff with in-line comments
Download patch
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 f73fa3ca540ceaa49c6aed0b7f3ef9399aab3343..6f65eef5255568e8bb48ac3e958e4dbe11c7c9e9 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 (enabled() && ShouldShowMenu() &&
IsTriggerableEvent(event) && HitTestPoint(event.location())) {
@@ -112,8 +104,7 @@ bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) {
// views::Button actions are only triggered by left and middle mouse clicks.
if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) {
- ink_drop_animation_controller_->AnimateToState(
- views::InkDropState::ACTION_PENDING);
+ ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING);
varkha 2015/11/27 22:07:50 Is there enough information in CustomButton to dri
bruthig 2015/12/07 18:44:46 Done.
}
return LabelButton::OnMousePressed(event);
@@ -145,7 +136,7 @@ void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) {
show_menu_factory_.InvalidateWeakPtrs();
if (!HitTestPoint(event.location()))
- ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN);
+ ink_drop_delegate()->OnAction(views::InkDropState::HIDDEN);
varkha 2015/11/27 22:07:50 I think this will move OnClickCanceled with https:
bruthig 2015/12/07 18:44:46 Done.
}
void ToolbarButton::OnMouseCaptureLost() {
@@ -167,32 +158,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) {
@@ -255,12 +220,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);
-}
-
bool ToolbarButton::ShouldShowMenu() {
return model_ != nullptr;
}
@@ -307,8 +266,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;
@@ -332,8 +290,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;

Powered by Google App Engine
This is Rietveld 408576698