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

Unified Diff: chrome/browser/ui/views/bar_control_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: Merged with master / https://codereview.chromium.org/1494433003. 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
Index: chrome/browser/ui/views/bar_control_button.cc
diff --git a/chrome/browser/ui/views/bar_control_button.cc b/chrome/browser/ui/views/bar_control_button.cc
index 6eb966be892f383899074e4fa5e3c05ea4e0a2e5..d58d7abe976920311c5b86db871a392da765db5e 100644
--- a/chrome/browser/ui/views/bar_control_button.cc
+++ b/chrome/browser/ui/views/bar_control_button.cc
@@ -7,8 +7,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.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/border.h"
namespace {
@@ -21,21 +20,22 @@ const int kButtonExtraTouchSize = 4;
BarControlButton::BarControlButton(views::ButtonListener* listener)
: views::ImageButton(listener),
id_(gfx::VectorIconId::VECTOR_ICON_NONE),
- ink_drop_animation_controller_(
- views::InkDropAnimationControllerFactory::
- CreateInkDropAnimationController(this)) {
+ ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) {
+ set_ink_drop_delegate(ink_drop_delegate_.get());
+
const int kInkDropLargeSize = 32;
const int kInkDropLargeCornerRadius = 4;
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);
}
-BarControlButton::~BarControlButton() {}
+BarControlButton::~BarControlButton() {
+ set_ink_drop_delegate(nullptr);
+ ink_drop_delegate_.reset();
+}
void BarControlButton::SetIcon(
gfx::VectorIconId id,
@@ -63,12 +63,6 @@ void BarControlButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
OnThemeChanged();
}
-void BarControlButton::Layout() {
- ImageButton::Layout();
-
- ink_drop_animation_controller_->SetInkDropCenter(CalculateInkDropCenter());
-}
-
void BarControlButton::AddInkDropLayer(ui::Layer* ink_drop_layer) {
// TODO(estade|tdanderson): The ink drop layer should be positioned behind
// the button's image.
@@ -89,54 +83,8 @@ gfx::Point BarControlButton::CalculateInkDropCenter() const {
}
bool BarControlButton::OnMousePressed(const ui::MouseEvent& event) {
- if (IsTriggerableEvent(event)) {
- ink_drop_animation_controller_->AnimateToState(
- views::InkDropState::ACTION_PENDING);
- }
+ if (IsTriggerableEvent(event))
+ ink_drop_delegate()->OnAction(views::InkDropState::ACTION_PENDING);
return ImageButton::OnMousePressed(event);
}
-
-void BarControlButton::OnGestureEvent(ui::GestureEvent* 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);
-
- ImageButton::OnGestureEvent(event);
-}
-
-void BarControlButton::OnMouseReleased(const ui::MouseEvent& event) {
- if (!HitTestPoint(event.location()))
- ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN);
-
- ImageButton::OnMouseReleased(event);
-}
-
-void BarControlButton::NotifyClick(const ui::Event& event) {
- ink_drop_animation_controller_->AnimateToState(
- views::InkDropState::QUICK_ACTION);
-
- ImageButton::NotifyClick(event);
-}

Powered by Google App Engine
This is Rietveld 408576698