Chromium Code Reviews| 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 4458ea7e244d800c386f5791afc4d6cf4e94e308..ce91eb7fa9d38644451484898e37e6bc2adc294d 100644 |
| --- a/ui/app_list/views/start_page_view.cc |
| +++ b/ui/app_list/views/start_page_view.cc |
| @@ -146,6 +146,7 @@ TileItemView* StartPageView::all_apps_button() const { |
| void StartPageView::OnShow() { |
| UpdateCustomPageClickzoneVisibility(); |
| + ClearSelectedIndex(); |
| } |
| void StartPageView::OnHide() { |
| @@ -163,7 +164,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)) |
|
Matt Giuca
2014/12/09 08:02:01
Question: Does this mean the all apps button will
calamity
2014/12/10 04:39:46
Yes.
Matt Giuca
2014/12/10 07:04:28
OK I will do it.
|
| + 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: |
| + dir = 1; |
| + break; |
| + case ui::VKEY_TAB: |
| + dir = event.IsShiftDown() ? -1 : 1; |
| + break; |
| + default: |
| + break; |
| + } |
| + |
| + if (dir == 0) |
| + return false; |
| + |
| + if (!IsValidSelectionIndex(selected_index())) { |
| + OnContainerSelected(dir == -1); |
|
Matt Giuca
2014/12/09 08:02:01
I don't really get why you use OnContainerSelected
calamity
2014/12/10 04:39:46
Eh. This is a bit of a semantic choice. I guess we
|
| + 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) { |
| + SetSelectedIndex(from_bottom ? num_results() - 1 : 0); |
| } |
| gfx::Rect StartPageView::GetSearchBoxBounds() const { |
| @@ -201,10 +243,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; |
|
Matt Giuca
2014/12/09 08:02:01
Is this result unrelated?
calamity
2014/12/10 04:39:46
Nope. Necessary to allow the all_apps_button_ to b
|
| } |
| 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 |