Commit c4f72ea2 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Make context menu anchor bounds match the highlight

AppListItemView got a new selection highlight, update the context menu
anchor bounds to match.

Also refactor slightly to prevent this error in the
future.

TEST=manual

Bug: 878161
Change-Id: I35649e9262925b45db8fcd801e8913d7111654b4
Reviewed-on: https://chromium-review.googlesource.com/1194995Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587304}
parent 3bdd397e
...@@ -394,8 +394,7 @@ void AppListItemView::OnContextMenuModelReceived( ...@@ -394,8 +394,7 @@ void AppListItemView::OnContextMenuModelReceived(
anchor_position = views::MENU_ANCHOR_BUBBLE_TOUCHABLE_RIGHT; anchor_position = views::MENU_ANCHOR_BUBBLE_TOUCHABLE_RIGHT;
anchor_rect = apps_grid_view_->GetIdealBounds(this); anchor_rect = apps_grid_view_->GetIdealBounds(this);
// Anchor the menu to the same rect that is used for selection highlight. // Anchor the menu to the same rect that is used for selection highlight.
anchor_rect.ClampToCenteredSize( AdaptBoundsForSelectionHighlight(&anchor_rect);
AppListConfig::instance().grid_focus_size());
views::View::ConvertRectToScreen(apps_grid_view_, &anchor_rect); views::View::ConvertRectToScreen(apps_grid_view_, &anchor_rect);
} }
...@@ -456,18 +455,17 @@ void AppListItemView::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -456,18 +455,17 @@ void AppListItemView::PaintButtonContents(gfx::Canvas* canvas) {
if (apps_grid_view_->IsDraggedView(this)) if (apps_grid_view_->IsDraggedView(this))
return; return;
gfx::Rect rect(GetContentsBounds());
if (apps_grid_view_->IsSelectedView(this)) { if (apps_grid_view_->IsSelectedView(this)) {
const int grid_focus_corner_radius =
AppListConfig::instance().grid_focus_corner_radius();
rect.Inset(0, 0, 0, AppListConfig::instance().grid_icon_bottom_padding());
rect.ClampToCenteredSize(AppListConfig::instance().grid_focus_size());
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setAntiAlias(true); flags.setAntiAlias(true);
flags.setColor(apps_grid_view_->is_in_folder() ? kFolderGridSelectedColor flags.setColor(apps_grid_view_->is_in_folder() ? kFolderGridSelectedColor
: kGridSelectedColor); : kGridSelectedColor);
flags.setStyle(cc::PaintFlags::kFill_Style); flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawRoundRect(gfx::RectF(rect), grid_focus_corner_radius, flags); gfx::Rect selection_highlight_bounds = GetContentsBounds();
AdaptBoundsForSelectionHighlight(&selection_highlight_bounds);
canvas->DrawRoundRect(gfx::RectF(selection_highlight_bounds),
AppListConfig::instance().grid_focus_corner_radius(),
flags);
} }
int preview_circle_radius = GetPreviewCircleRadius(); int preview_circle_radius = GetPreviewCircleRadius();
...@@ -848,4 +846,9 @@ void AppListItemView::CreateDraggedViewHoverAnimation() { ...@@ -848,4 +846,9 @@ void AppListItemView::CreateDraggedViewHoverAnimation() {
kDraggedViewHoverAnimationDuration); kDraggedViewHoverAnimationDuration);
} }
void AppListItemView::AdaptBoundsForSelectionHighlight(gfx::Rect* bounds) {
bounds->Inset(0, 0, 0, AppListConfig::instance().grid_icon_bottom_padding());
bounds->ClampToCenteredSize(AppListConfig::instance().grid_focus_size());
}
} // namespace app_list } // namespace app_list
...@@ -212,6 +212,9 @@ class APP_LIST_EXPORT AppListItemView ...@@ -212,6 +212,9 @@ class APP_LIST_EXPORT AppListItemView
// Creates dragged view hover animation if it does not exist. // Creates dragged view hover animation if it does not exist.
void CreateDraggedViewHoverAnimation(); void CreateDraggedViewHoverAnimation();
// Modifies AppListItemView bounds to match the selected highlight bounds.
void AdaptBoundsForSelectionHighlight(gfx::Rect* rect);
const bool is_folder_; const bool is_folder_;
const bool is_in_folder_; const bool is_in_folder_;
......
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