| 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/start_page_view.h" | 5 #include "ui/app_list/views/start_page_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 TileItemView* GetTileItemView(int index); | 120 TileItemView* GetTileItemView(int index); |
| 121 | 121 |
| 122 const std::vector<SearchResultTileItemView*>& tile_views() const { | 122 const std::vector<SearchResultTileItemView*>& tile_views() const { |
| 123 return search_result_tile_views_; | 123 return search_result_tile_views_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 AllAppsTileItemView* all_apps_button() { return all_apps_button_; } | 126 AllAppsTileItemView* all_apps_button() { return all_apps_button_; } |
| 127 | 127 |
| 128 // Overridden from SearchResultContainerView: | 128 // Overridden from SearchResultContainerView: |
| 129 int Update() override; | 129 int DoUpdate() override; |
| 130 void UpdateSelectedIndex(int old_selected, int new_selected) override; | 130 void UpdateSelectedIndex(int old_selected, int new_selected) override; |
| 131 void OnContainerSelected(bool from_bottom, | 131 void OnContainerSelected(bool from_bottom, |
| 132 bool directional_movement) override; | 132 bool directional_movement) override; |
| 133 void NotifyFirstResultYIndex(int y_index) override; | 133 void NotifyFirstResultYIndex(int y_index) override; |
| 134 int GetYSize() override; | 134 int GetYSize() override; |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 void CreateAppsGrid(int apps_num); | 137 void CreateAppsGrid(int apps_num); |
| 138 | 138 |
| 139 ContentsView* contents_view_; | 139 ContentsView* contents_view_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 164 | 164 |
| 165 TileItemView* StartPageView::StartPageTilesContainer::GetTileItemView( | 165 TileItemView* StartPageView::StartPageTilesContainer::GetTileItemView( |
| 166 int index) { | 166 int index) { |
| 167 DCHECK_GT(num_results(), index); | 167 DCHECK_GT(num_results(), index); |
| 168 if (index == num_results() - 1) | 168 if (index == num_results() - 1) |
| 169 return all_apps_button_; | 169 return all_apps_button_; |
| 170 | 170 |
| 171 return search_result_tile_views_[index]; | 171 return search_result_tile_views_[index]; |
| 172 } | 172 } |
| 173 | 173 |
| 174 int StartPageView::StartPageTilesContainer::Update() { | 174 int StartPageView::StartPageTilesContainer::DoUpdate() { |
| 175 // Ignore updates and disable buttons when transitioning to a different | 175 // Ignore updates and disable buttons when transitioning to a different |
| 176 // state. | 176 // state. |
| 177 if (contents_view_->GetActiveState() != AppListModel::STATE_START) { | 177 if (contents_view_->GetActiveState() != AppListModel::STATE_START) { |
| 178 for (auto* view : search_result_tile_views_) | 178 for (auto* view : search_result_tile_views_) |
| 179 view->SetEnabled(false); | 179 view->SetEnabled(false); |
| 180 | 180 |
| 181 return num_results(); | 181 return num_results(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 std::vector<SearchResult*> display_results = | 184 std::vector<SearchResult*> display_results = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 204 | 204 |
| 205 Layout(); | 205 Layout(); |
| 206 parent()->Layout(); | 206 parent()->Layout(); |
| 207 // Add 1 to the results size to account for the all apps button. | 207 // Add 1 to the results size to account for the all apps button. |
| 208 return display_results.size() + 1; | 208 return display_results.size() + 1; |
| 209 } | 209 } |
| 210 | 210 |
| 211 void StartPageView::StartPageTilesContainer::UpdateSelectedIndex( | 211 void StartPageView::StartPageTilesContainer::UpdateSelectedIndex( |
| 212 int old_selected, | 212 int old_selected, |
| 213 int new_selected) { | 213 int new_selected) { |
| 214 if (old_selected >= 0) | 214 if (old_selected >= 0 && old_selected < num_results()) |
| 215 GetTileItemView(old_selected)->SetSelected(false); | 215 GetTileItemView(old_selected)->SetSelected(false); |
| 216 | 216 |
| 217 if (new_selected >= 0) | 217 if (new_selected >= 0 && new_selected < num_results()) |
| 218 GetTileItemView(new_selected)->SetSelected(true); | 218 GetTileItemView(new_selected)->SetSelected(true); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void StartPageView::StartPageTilesContainer::OnContainerSelected( | 221 void StartPageView::StartPageTilesContainer::OnContainerSelected( |
| 222 bool /*from_bottom*/, | 222 bool /*from_bottom*/, |
| 223 bool /*directional_movement*/) { | 223 bool /*directional_movement*/) { |
| 224 NOTREACHED(); | 224 NOTREACHED(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void StartPageView::StartPageTilesContainer::NotifyFirstResultYIndex( | 227 void StartPageView::StartPageTilesContainer::NotifyFirstResultYIndex( |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 void StartPageView::OnShown() { | 354 void StartPageView::OnShown() { |
| 355 // When the start page is shown, show or hide the custom launcher page | 355 // When the start page is shown, show or hide the custom launcher page |
| 356 // based on whether it is enabled. | 356 // based on whether it is enabled. |
| 357 CustomLauncherPageView* custom_page_view = | 357 CustomLauncherPageView* custom_page_view = |
| 358 app_list_main_view_->contents_view()->custom_page_view(); | 358 app_list_main_view_->contents_view()->custom_page_view(); |
| 359 if (custom_page_view) { | 359 if (custom_page_view) { |
| 360 custom_page_view->SetVisible( | 360 custom_page_view->SetVisible( |
| 361 app_list_main_view_->ShouldShowCustomLauncherPage()); | 361 app_list_main_view_->ShouldShowCustomLauncherPage()); |
| 362 } | 362 } |
| 363 tiles_container_->ClearSelectedIndex(); |
| 363 tiles_container_->Update(); | 364 tiles_container_->Update(); |
| 364 tiles_container_->ClearSelectedIndex(); | |
| 365 custom_launcher_page_background_->SetSelected(false); | 365 custom_launcher_page_background_->SetSelected(false); |
| 366 } | 366 } |
| 367 | 367 |
| 368 gfx::Rect StartPageView::GetPageBoundsForState( | 368 gfx::Rect StartPageView::GetPageBoundsForState( |
| 369 AppListModel::State state) const { | 369 AppListModel::State state) const { |
| 370 gfx::Rect onscreen_bounds(GetFullContentsBounds()); | 370 gfx::Rect onscreen_bounds(GetFullContentsBounds()); |
| 371 if (state == AppListModel::STATE_START) | 371 if (state == AppListModel::STATE_START) |
| 372 return onscreen_bounds; | 372 return onscreen_bounds; |
| 373 | 373 |
| 374 return GetAboveContentsOffscreenBounds(onscreen_bounds.size()); | 374 return GetAboveContentsOffscreenBounds(onscreen_bounds.size()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // is enabled). | 527 // is enabled). |
| 528 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) | 528 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) |
| 529 MaybeOpenCustomLauncherPage(); | 529 MaybeOpenCustomLauncherPage(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 TileItemView* StartPageView::GetTileItemView(size_t index) { | 532 TileItemView* StartPageView::GetTileItemView(size_t index) { |
| 533 return tiles_container_->GetTileItemView(index); | 533 return tiles_container_->GetTileItemView(index); |
| 534 } | 534 } |
| 535 | 535 |
| 536 } // namespace app_list | 536 } // namespace app_list |
| OLD | NEW |