Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: ui/app_list/views/start_page_view.cc

Issue 307333002: Add search results to experimental app list start page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments, fix for breaking a test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/start_page_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 697352cb8893c5206246cd8b6922f91aae64834b..e4d6487aa663f63f8c504426b1bb9390c56da275 100644
--- a/ui/app_list/views/start_page_view.cc
+++ b/ui/app_list/views/start_page_view.cc
@@ -10,6 +10,7 @@
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/views/app_list_main_view.h"
+#include "ui/app_list/views/search_result_list_view.h"
#include "ui/app_list/views/tile_item_view.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/button/custom_button.h"
@@ -76,15 +77,17 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view,
: app_list_main_view_(app_list_main_view),
model_(NULL),
view_delegate_(view_delegate),
+ results_view_(
+ new SearchResultListView(app_list_main_view, view_delegate)),
instant_container_(new views::View),
- tiles_container_(new views::View) {
- SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing));
-
+ tiles_container_(new views::View),
+ show_state_(SHOW_START_PAGE) {
// The view containing the start page WebContents and the BarPlaceholder.
AddChildView(instant_container_);
views::BoxLayout* instant_layout_manager = new views::BoxLayout(
views::BoxLayout::kVertical, 0, 0, kInstantContainerSpacing);
+ instant_layout_manager->set_inside_border_insets(
+ gfx::Insets(kTopMargin, 0, kInstantContainerSpacing, 0));
instant_layout_manager->set_main_axis_alignment(
views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
instant_container_->SetLayoutManager(instant_layout_manager);
@@ -95,6 +98,9 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view,
instant_container_->AddChildView(web_view);
instant_container_->AddChildView(new BarPlaceholderButton(this));
+ // The view containing the search results.
+ AddChildView(results_view_);
+
// The view containing the start page tiles.
AddChildView(tiles_container_);
views::BoxLayout* tiles_layout_manager =
@@ -124,11 +130,12 @@ void StartPageView::SetModel(AppListModel* model) {
model_->RemoveObserver(this);
model_ = model;
model_->AddObserver(this);
+ results_view_->SetResults(model_->results());
Reset();
}
void StartPageView::Reset() {
- instant_container_->SetVisible(true);
+ SetShowState(SHOW_START_PAGE);
if (!model_ || !model_->top_level_item_list())
return;
@@ -138,14 +145,53 @@ void StartPageView::Reset() {
item = model_->top_level_item_list()->item_at(i);
tile_views_[i]->SetAppListItem(item);
}
+}
+
+void StartPageView::ShowSearchResults() {
+ SetShowState(SHOW_SEARCH_RESULTS);
+}
+
+void StartPageView::SetShowState(ShowState show_state) {
+ instant_container_->SetVisible(show_state == SHOW_START_PAGE);
+ results_view_->SetVisible(show_state == SHOW_SEARCH_RESULTS);
+
+ if (show_state_ == show_state)
+ return;
+
+ show_state_ = show_state;
+
+ results_view_->UpdateAutoLaunchState();
+ if (show_state == SHOW_SEARCH_RESULTS)
+ results_view_->SetSelectedIndex(0);
+}
+
+bool StartPageView::IsShowingSearchResults() const {
+ return show_state_ == SHOW_SEARCH_RESULTS;
+}
+
+bool StartPageView::OnKeyPressed(const ui::KeyEvent& event) {
+ if (show_state_ == SHOW_SEARCH_RESULTS)
+ return results_view_->OnKeyPressed(event);
+
+ return false;
+}
- Layout();
+void StartPageView::Layout() {
+ // Instant and search results take up the height of the instant container.
+ gfx::Rect bounds(GetContentsBounds());
+ bounds.set_height(instant_container_->GetHeightForWidth(bounds.width()));
+ instant_container_->SetBoundsRect(bounds);
+ results_view_->SetBoundsRect(bounds);
+
+ // Tiles begin where the instant container ends.
+ bounds.set_y(bounds.bottom());
+ bounds.set_height(tiles_container_->GetHeightForWidth(bounds.width()));
+ tiles_container_->SetBoundsRect(bounds);
}
void StartPageView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
app_list_main_view_->OnStartPageSearchButtonPressed();
- instant_container_->SetVisible(false);
}
void StartPageView::OnProfilesChanged() {
« no previous file with comments | « ui/app_list/views/start_page_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698