Commit dc649dc3 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Make GetInkDrop() method public so it can be externally configured.

Also using this public InkDrop interface from ConfigureBubbleMenuItem
to remove the hover animations.

Bug: 1015634
Change-Id: Iadc2256625c9b8aaca6ec283f96a95e8f06ae265
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954938Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722679}
parent 887fa92f
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "chrome/browser/ui/views/hover_button.h" #include "chrome/browser/ui/views/hover_button.h"
#include "chrome/browser/ui/views/hover_button_controller.h" #include "chrome/browser/ui/views/hover_button_controller.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_host_view.h" #include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -22,6 +23,8 @@ void ConfigureBubbleMenuItem(views::Button* button, int button_id) { ...@@ -22,6 +23,8 @@ void ConfigureBubbleMenuItem(views::Button* button, int button_id) {
// Items within a menu should not show focus rings. // Items within a menu should not show focus rings.
button->SetInstallFocusRingOnFocus(false); button->SetInstallFocusRingOnFocus(false);
button->SetInkDropMode(views::InkDropHostView::InkDropMode::ON); button->SetInkDropMode(views::InkDropHostView::InkDropMode::ON);
button->GetInkDrop()->SetShowHighlightOnFocus(true);
button->GetInkDrop()->SetHoverHighlightFadeDuration(base::TimeDelta());
views::InstallRectHighlightPathGenerator(button); views::InstallRectHighlightPathGenerator(button);
button->set_ink_drop_base_color(HoverButton::GetInkDropColor(button)); button->set_ink_drop_base_color(HoverButton::GetInkDropColor(button));
button->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); button->SetFocusBehavior(views::View::FocusBehavior::ALWAYS);
......
...@@ -111,6 +111,17 @@ void InkDropHostView::AnimateInkDrop(InkDropState state, ...@@ -111,6 +111,17 @@ void InkDropHostView::AnimateInkDrop(InkDropState state,
GetEventHandler()->AnimateInkDrop(state, event); GetEventHandler()->AnimateInkDrop(state, event);
} }
InkDrop* InkDropHostView::GetInkDrop() {
if (!ink_drop_) {
if (ink_drop_mode_ == InkDropMode::OFF)
ink_drop_ = std::make_unique<InkDropStub>();
else
ink_drop_ = CreateInkDrop();
OnInkDropCreated();
}
return ink_drop_.get();
}
std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() { std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() {
auto ink_drop = std::make_unique<InkDropImpl>(this, size()); auto ink_drop = std::make_unique<InkDropImpl>(this, size());
ink_drop->SetAutoHighlightMode( ink_drop->SetAutoHighlightMode(
...@@ -161,17 +172,6 @@ bool InkDropHostView::HasInkDrop() const { ...@@ -161,17 +172,6 @@ bool InkDropHostView::HasInkDrop() const {
return !!ink_drop_; return !!ink_drop_;
} }
InkDrop* InkDropHostView::GetInkDrop() {
if (!ink_drop_) {
if (ink_drop_mode_ == InkDropMode::OFF)
ink_drop_ = std::make_unique<InkDropStub>();
else
ink_drop_ = CreateInkDrop();
OnInkDropCreated();
}
return ink_drop_.get();
}
gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const { gfx::Point InkDropHostView::GetInkDropCenterBasedOnLastEvent() const {
return GetEventHandler()->GetLastRippleTriggeringEvent() return GetEventHandler()->GetLastRippleTriggeringEvent()
? GetEventHandler()->GetLastRippleTriggeringEvent()->location() ? GetEventHandler()->GetLastRippleTriggeringEvent()->location()
......
...@@ -132,6 +132,16 @@ class VIEWS_EXPORT InkDropHostView : public View { ...@@ -132,6 +132,16 @@ class VIEWS_EXPORT InkDropHostView : public View {
// them. // them.
void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event); void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event);
// Provides public access to |ink_drop_| so that factory methods can configure
// the inkdrop. Implements lazy initialization of |ink_drop_| so as to avoid
// virtual method calls during construction since subclasses should be able to
// call SetInkDropMode() during construction.
//
// WARNING: please don't override this; this is only virtual for the
// InstallableInkDrop refactor. TODO(crbug.com/931964): make non-virtual when
// this isn't necessary anymore.
virtual InkDrop* GetInkDrop();
protected: protected:
// Size used for the default SquareInkDropRipple. // Size used for the default SquareInkDropRipple.
static constexpr gfx::Size kDefaultInkDropSize = gfx::Size(24, 24); static constexpr gfx::Size kDefaultInkDropSize = gfx::Size(24, 24);
...@@ -172,15 +182,6 @@ class VIEWS_EXPORT InkDropHostView : public View { ...@@ -172,15 +182,6 @@ class VIEWS_EXPORT InkDropHostView : public View {
// Returns true if an ink drop instance has been created. // Returns true if an ink drop instance has been created.
bool HasInkDrop() const; bool HasInkDrop() const;
// Provides access to |ink_drop_|. Implements lazy initialization of
// |ink_drop_| so as to avoid virtual method calls during construction since
// subclasses should be able to call SetInkDropMode() during construction.
//
// WARNING: please don't override this; this is only virtual for the
// InstallableInkDrop refactor. TODO(crbug.com/931964): make non-virtual when
// this isn't necessary anymore.
virtual InkDrop* GetInkDrop();
// Returns the point of the |last_ripple_triggering_event_| if it was a // Returns the point of the |last_ripple_triggering_event_| if it was a
// LocatedEvent, otherwise the center point of the local bounds is returned. // LocatedEvent, otherwise the center point of the local bounds is returned.
gfx::Point GetInkDropCenterBasedOnLastEvent() const; gfx::Point GetInkDropCenterBasedOnLastEvent() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment