Commit 0d775506 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Show selection highlight on shelf when a menu shows

Per UX Request:
For all MenuShowSource types, show a highlight when a menu is shown.

This was already working for touch menus.

This also fixes the bug where the ink drop bubble was "Bursting"
regardless of the prior ink drop state.

Bug: 844779
Change-Id: I715300a7447ad099b6a610b34e8a30a2170d6e4c
Reviewed-on: https://chromium-review.googlesource.com/1095637Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567488}
parent 60b9c53d
......@@ -399,8 +399,9 @@ void ShelfButton::OnDragStarted(const ui::LocatedEvent* event) {
}
void ShelfButton::OnMenuClosed() {
if (GetInkDrop()->GetTargetInkDropState() != views::InkDropState::DEACTIVATED)
GetInkDrop()->AnimateToState(views::InkDropState::DEACTIVATED);
DCHECK_EQ(views::InkDropState::ACTIVATED,
GetInkDrop()->GetTargetInkDropState());
GetInkDrop()->AnimateToState(views::InkDropState::DEACTIVATED);
}
void ShelfButton::ShowContextMenu(const gfx::Point& p,
......@@ -413,6 +414,10 @@ void ShelfButton::ShowContextMenu(const gfx::Point& p,
Button::ShowContextMenu(p, source_type);
if (source_type == ui::MenuSourceType::MENU_SOURCE_MOUSE ||
source_type == ui::MenuSourceType::MENU_SOURCE_KEYBOARD) {
GetInkDrop()->AnimateToState(views::InkDropState::ACTIVATED);
}
if (!destroyed) {
destroyed_flag_ = nullptr;
// The menu will not propagate mouse events while its shown. To address,
......@@ -574,8 +579,11 @@ void ShelfButton::OnGestureEvent(ui::GestureEvent* event) {
// If the button is being dragged, or there is an active context menu,
// for this ShelfButton, don't deactivate the ink drop.
if (!(state_ & STATE_DRAGGING) &&
!shelf_view_->IsShowingMenuForView(this))
!shelf_view_->IsShowingMenuForView(this) &&
(GetInkDrop()->GetTargetInkDropState() ==
views::InkDropState::ACTIVATED)) {
GetInkDrop()->AnimateToState(views::InkDropState::DEACTIVATED);
}
ClearState(STATE_HOVERED);
ClearState(STATE_DRAGGING);
break;
......
......@@ -2012,7 +2012,7 @@ void ShelfView::OnMenuClosed(views::View* source) {
closing_event_time_ = shelf_menu_model_adapter_->GetClosingEventTime();
const ShelfItem* item = ShelfItemForView(source);
if (item)
if (item && (item->type != TYPE_APP_LIST))
static_cast<ShelfButton*>(source)->OnMenuClosed();
shelf_menu_model_adapter_.reset();
......
......@@ -2018,6 +2018,23 @@ TEST_F(ShelfViewTest, AppListButtonShowsContextMenu) {
EXPECT_TRUE(test_api_->CloseMenu());
}
// Tests that a ShelfButton ink drop highlight is set to ACTIVATED when a menu
// is shown by mouse.
TEST_F(ShelfViewTest, ShelfButtonShowsInkDropHighlightOnMenuShow) {
const ShelfID id_0 = AddApp();
ShelfButton* button_0 = GetButtonByID(id_0);
ui::test::EventGenerator& generator = GetEventGenerator();
generator.MoveMouseTo(button_0->GetBoundsInScreen().CenterPoint());
generator.PressRightButton();
EXPECT_EQ(views::InkDropState::ACTIVATED,
button_0->GetInkDropForTesting()->GetTargetInkDropState());
// Close the menu, the InkDropState should transition to HIDDEN.
EXPECT_TRUE(test_api_->CloseMenu());
EXPECT_EQ(views::InkDropState::HIDDEN,
button_0->GetInkDropForTesting()->GetTargetInkDropState());
}
// Tests that ShelfWindowWatcher buttons show a context menu on right click.
TEST_F(ShelfViewTest, ShelfWindowWatcherButtonShowsContextMenu) {
ui::test::EventGenerator& generator = GetEventGenerator();
......
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