Commit 8e041f02 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Add flag to show the ink-drop highlight when SetHotTracked() is called.

Set hide_ink_drop_when_showing_context_menu to false.

Bug: 1001931
Change-Id: I6e61db469ae0291a4041d18e52e3317671e47c91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1791628
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Auto-Submit: Allen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695594}
parent 670e6b02
......@@ -67,6 +67,8 @@ ToolbarActionView::ToolbarActionView(
delegate_(delegate) {
SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
set_hide_ink_drop_when_showing_context_menu(false);
set_show_ink_drop_when_hot_tracked(true);
SetID(VIEW_ID_BROWSER_ACTION);
view_controller_->SetDelegate(this);
SetHorizontalAlignment(gfx::ALIGN_CENTER);
......@@ -272,23 +274,6 @@ void ToolbarActionView::ViewHierarchyChanged(
MenuButton::ViewHierarchyChanged(details);
}
void ToolbarActionView::StateChanged(views::Button::ButtonState old_state) {
MenuButton::StateChanged(old_state);
if (delegate_->ShownInsideMenu()) {
// The following code is necessary to ensure the item is properly
// highlighted when using keyboard navigation to select items in the menu.
// InkDrops will listen for hover events and highlight accordingly. However,
// menu items don't actually get focus so using SetShowHighlightOnFocus()
// won't work. The button state is set to STATE_HOVERED, so this code will
// ensure the InkDrop actually highlights.
views::InkDropState target_state = state() == views::Button::STATE_HOVERED
? views::InkDropState::ACTIVATED
: views::InkDropState::HIDDEN;
if (GetInkDrop()->GetTargetInkDropState() != target_state)
AnimateInkDrop(target_state, nullptr);
}
}
views::View* ToolbarActionView::GetAsView() {
return this;
}
......
......@@ -108,7 +108,6 @@ class ToolbarActionView : public views::MenuButton,
void OnDragDone() override;
void ViewHierarchyChanged(
const views::ViewHierarchyChangedDetails& details) override;
void StateChanged(views::Button::ButtonState old_state) override;
// ToolbarActionViewDelegateViews:
views::View* GetAsView() override;
......
......@@ -239,8 +239,14 @@ void Button::SetInstallFocusRingOnFocus(bool install) {
}
void Button::SetHotTracked(bool is_hot_tracked) {
if (state_ != STATE_DISABLED)
if (state_ != STATE_DISABLED) {
SetState(is_hot_tracked ? STATE_HOVERED : STATE_NORMAL);
if (show_ink_drop_when_hot_tracked_) {
AnimateInkDrop(is_hot_tracked ? views::InkDropState::ACTIVATED
: views::InkDropState::HIDDEN,
nullptr);
}
}
if (is_hot_tracked)
NotifyAccessibilityEvent(ax::mojom::Event::kHover, true);
......
......@@ -149,12 +149,19 @@ class VIEWS_EXPORT Button : public InkDropHostView,
animate_on_state_change_ = value;
}
bool hide_ink_drop_when_showing_context_menu() const {
return hide_ink_drop_when_showing_context_menu_;
}
void set_hide_ink_drop_when_showing_context_menu(
bool hide_ink_drop_when_showing_context_menu) {
hide_ink_drop_when_showing_context_menu_ =
hide_ink_drop_when_showing_context_menu;
}
void set_show_ink_drop_when_hot_tracked(bool show_ink_drop_when_hot_tracked) {
show_ink_drop_when_hot_tracked_ = show_ink_drop_when_hot_tracked;
}
void set_ink_drop_base_color(SkColor color) { ink_drop_base_color_ = color; }
void set_has_ink_drop_action_on_click(bool has_ink_drop_action_on_click) {
has_ink_drop_action_on_click_ = has_ink_drop_action_on_click;
......@@ -346,6 +353,10 @@ class VIEWS_EXPORT Button : public InkDropHostView,
// the context menu.
bool hide_ink_drop_when_showing_context_menu_ = true;
// When true, the ink drop ripple will be shown when setting state to hot
// tracked with SetHotTracked().
bool show_ink_drop_when_hot_tracked_ = false;
// The color of the ripple and hover.
SkColor ink_drop_base_color_;
......
......@@ -102,7 +102,8 @@ void MenuButtonController::OnMouseReleased(const ui::MouseEvent& event) {
button()->HitTestPoint(event.location()) && !delegate()->InDrag()) {
Activate(&event);
} else {
button()->AnimateInkDrop(InkDropState::HIDDEN, &event);
if (button()->hide_ink_drop_when_showing_context_menu())
button()->AnimateInkDrop(InkDropState::HIDDEN, &event);
ButtonController::OnMouseReleased(event);
}
}
......
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