OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/views/search_result_tile_item_list_view.h" | 5 #include "ui/app_list/views/search_result_tile_item_list_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 if (old_selected >= 0) | 162 if (old_selected >= 0) |
163 tile_views_[old_selected]->SetSelected(false); | 163 tile_views_[old_selected]->SetSelected(false); |
164 | 164 |
165 if (new_selected >= 0) { | 165 if (new_selected >= 0) { |
166 tile_views_[new_selected]->SetSelected(true); | 166 tile_views_[new_selected]->SetSelected(true); |
167 ScrollRectToVisible(GetLocalBounds()); | 167 ScrollRectToVisible(GetLocalBounds()); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) { | 171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) { |
172 if (selected_index() >= 0 && child_at(selected_index())->OnKeyPressed(event)) | 172 int selection_index = selected_index(); |
173 // Also count the separator when Play Store app search feature is enabled. | |
174 int child_index = is_play_store_app_search_enabled_ ? selection_index * 2 + 1 | |
khmel
2017/07/18 15:04:01
nit: const int
Jiaquan He
2017/07/18 15:58:16
Done.
| |
175 : selection_index; | |
176 if (selection_index >= 0 && child_at(child_index)->OnKeyPressed(event)) | |
173 return true; | 177 return true; |
174 | 178 |
175 int dir = 0; | 179 int dir = 0; |
176 bool cursor_at_end_of_searchbox = | 180 bool cursor_at_end_of_searchbox = |
177 search_box_->GetCursorPosition() == search_box_->text().length(); | 181 search_box_->GetCursorPosition() == search_box_->text().length(); |
178 const int forward_dir = base::i18n::IsRTL() ? -1 : 1; | 182 const int forward_dir = base::i18n::IsRTL() ? -1 : 1; |
179 switch (event.key_code()) { | 183 switch (event.key_code()) { |
180 case ui::VKEY_TAB: | 184 case ui::VKEY_TAB: |
181 if (event.IsShiftDown()) | 185 if (event.IsShiftDown()) |
182 dir = -1; | 186 dir = -1; |
(...skipping 14 matching lines...) Expand all Loading... | |
197 // text. | 201 // text. |
198 if (cursor_at_end_of_searchbox) | 202 if (cursor_at_end_of_searchbox) |
199 dir = forward_dir; | 203 dir = forward_dir; |
200 break; | 204 break; |
201 default: | 205 default: |
202 break; | 206 break; |
203 } | 207 } |
204 if (dir == 0) | 208 if (dir == 0) |
205 return false; | 209 return false; |
206 | 210 |
207 int selection_index = selected_index() + dir; | 211 selection_index = selection_index + dir; |
208 if (IsValidSelectionIndex(selection_index)) { | 212 if (IsValidSelectionIndex(selection_index)) { |
209 SetSelectedIndex(selection_index); | 213 SetSelectedIndex(selection_index); |
210 return true; | 214 return true; |
211 } | 215 } |
212 | 216 |
213 return false; | 217 return false; |
214 } | 218 } |
215 | 219 |
216 } // namespace app_list | 220 } // namespace app_list |
OLD | NEW |