Index: ui/app_list/views/start_page_view.cc |
diff --git a/ui/app_list/views/start_page_view.cc b/ui/app_list/views/start_page_view.cc |
index 45fa3942a7a693b80a87f86d47ce25bd1d1d726a..e9ab1de1c4ea60dd73999db1f5e1afbb0fa1e6c1 100644 |
--- a/ui/app_list/views/start_page_view.cc |
+++ b/ui/app_list/views/start_page_view.cc |
@@ -147,6 +147,7 @@ TileItemView* StartPageView::all_apps_button() const { |
void StartPageView::OnShow() { |
DCHECK(app_list_main_view_->contents_view()->ShouldShowCustomPageClickzone()); |
UpdateCustomPageClickzoneVisibility(); |
+ ClearSelectedIndex(); |
} |
void StartPageView::OnHide() { |
@@ -166,6 +167,48 @@ void StartPageView::Layout() { |
tiles_container_->SetBoundsRect(bounds); |
} |
+bool StartPageView::OnKeyPressed(const ui::KeyEvent& event) { |
+ if (selected_index() >= 0 && |
+ tiles_container_->child_at(selected_index())->OnKeyPressed(event)) |
+ return true; |
+ |
+ int dir = 0; |
+ switch (event.key_code()) { |
+ case ui::VKEY_LEFT: |
+ dir = -1; |
+ break; |
+ case ui::VKEY_RIGHT: |
+ dir = 1; |
+ break; |
+ case ui::VKEY_DOWN: |
+ // Down selects the first tile if nothing is selected. |
+ if (!IsValidSelectionIndex(selected_index())) |
+ dir = 1; |
+ break; |
+ case ui::VKEY_TAB: |
+ dir = event.IsShiftDown() ? -1 : 1; |
+ break; |
+ default: |
+ break; |
+ } |
+ |
+ if (dir == 0) |
+ return false; |
+ |
+ if (!IsValidSelectionIndex(selected_index())) { |
+ SetSelectedIndex(dir == -1 ? num_results() - 1 : 0); |
+ return true; |
+ } |
+ |
+ int selection_index = selected_index() + dir; |
+ if (IsValidSelectionIndex(selection_index)) { |
+ SetSelectedIndex(selection_index); |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
void StartPageView::OnContainerSelected(bool from_bottom) { |
} |
@@ -204,10 +247,22 @@ int StartPageView::Update() { |
tiles_container_->Layout(); |
Layout(); |
- return display_results.size(); |
+ // Add 1 to the results size to account for the all apps button. |
+ return display_results.size() + 1; |
} |
void StartPageView::UpdateSelectedIndex(int old_selected, int new_selected) { |
+ if (old_selected >= 0) { |
+ tiles_container_->child_at(old_selected)->set_background(nullptr); |
+ tiles_container_->child_at(old_selected)->SchedulePaint(); |
+ } |
+ |
+ if (new_selected >= 0) { |
+ tiles_container_->child_at(new_selected) |
+ ->set_background( |
+ views::Background::CreateSolidBackground(kSelectedColor)); |
+ tiles_container_->child_at(new_selected)->SchedulePaint(); |
+ } |
} |
} // namespace app_list |