Commit 2b7b3c8c authored by mukai's avatar mukai Committed by Commit bot

Reset the background of title label when selected by arrow keys.

In the old app-list, the key selection doesn't signal any events
to AppListItemView, so it can't update the background color at
that point.

BUG=467517
R=mgiuca@chromium.org

Review URL: https://codereview.chromium.org/1010853002

Cr-Commit-Position: refs/heads/master@{#320800}
parent 0f07fbef
......@@ -205,28 +205,6 @@ void AppListItemView::OnMouseDragTimer() {
SetUIState(UI_STATE_DRAGGING);
}
void AppListItemView::SetTitleSubpixelAA() {
// TODO(tapted): Enable AA for folders as well, taking care to play nice with
// the folder bubble animation.
bool enable_aa = !is_in_folder_ && ui_state_ == UI_STATE_NORMAL &&
!is_highlighted_ && !apps_grid_view_->IsSelectedView(this) &&
!apps_grid_view_->IsAnimatingView(this);
title_->SetSubpixelRenderingEnabled(enable_aa);
if (enable_aa) {
title_->SetBackgroundColor(app_list::kLabelBackgroundColor);
title_->set_background(views::Background::CreateSolidBackground(
app_list::kLabelBackgroundColor));
} else {
// In other cases, keep the background transparent to ensure correct
// interactions with animations. This will temporarily disable subpixel AA.
title_->SetBackgroundColor(0);
title_->set_background(NULL);
}
title_->Invalidate();
title_->SchedulePaint();
}
void AppListItemView::Prerender() {
title_->PaintToBackingImage();
}
......@@ -567,6 +545,28 @@ gfx::Rect AppListItemView::GetIconBoundsForTargetViewBounds(
return icon_bounds;
}
void AppListItemView::SetTitleSubpixelAA() {
// TODO(tapted): Enable AA for folders as well, taking care to play nice with
// the folder bubble animation.
bool enable_aa = !is_in_folder_ && ui_state_ == UI_STATE_NORMAL &&
!is_highlighted_ && !apps_grid_view_->IsSelectedView(this) &&
!apps_grid_view_->IsAnimatingView(this);
title_->SetSubpixelRenderingEnabled(enable_aa);
if (enable_aa) {
title_->SetBackgroundColor(app_list::kLabelBackgroundColor);
title_->set_background(views::Background::CreateSolidBackground(
app_list::kLabelBackgroundColor));
} else {
// In other cases, keep the background transparent to ensure correct
// interactions with animations. This will temporarily disable subpixel AA.
title_->SetBackgroundColor(0);
title_->set_background(NULL);
}
title_->Invalidate();
title_->SchedulePaint();
}
void AppListItemView::ItemIconChanged() {
SetIcon(item_weak_->icon(), item_weak_->has_shadow());
}
......
......@@ -81,6 +81,10 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
// the assuming bounds of this view.
gfx::Rect GetIconBoundsForTargetViewBounds(const gfx::Rect& target_bounds);
// If the item is not in a folder, not highlighted, not being dragged, and not
// having something dropped onto it, enables subpixel AA for the title.
void SetTitleSubpixelAA();
// views::CustomButton overrides:
void OnGestureEvent(ui::GestureEvent* event) override;
......@@ -109,10 +113,6 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
// Invoked when |mouse_drag_timer_| fires to show dragging UI.
void OnMouseDragTimer();
// If the item is not in a folder, not highlighted, not being dragged, and not
// having something dropped onto it, enables subpixel AA for the title.
void SetTitleSubpixelAA();
// views::View overrides:
const char* GetClassName() const override;
void Layout() override;
......
......@@ -1110,6 +1110,7 @@ void AppsGridView::SetSelectedItemByIndex(const Index& index) {
EnsureViewVisible(index);
selected_view_ = new_selection;
selected_view_->SetTitleSubpixelAA();
selected_view_->SchedulePaint();
selected_view_->NotifyAccessibilityEvent(
ui::AX_EVENT_FOCUS, true);
......
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