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

Side by Side Diff: athena/home/bottom_home_view.cc

Issue 439703002: Allow app list tiles to show search results in the experimental app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix athena Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "athena/home/bottom_home_view.h" 5 #include "athena/home/bottom_home_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/app_list/app_list_item.h"
7 #include "ui/app_list/app_list_item_list.h" 9 #include "ui/app_list/app_list_item_list.h"
8 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
9 #include "ui/app_list/app_list_view_delegate.h" 11 #include "ui/app_list/app_list_view_delegate.h"
10 #include "ui/app_list/views/search_box_view.h" 12 #include "ui/app_list/views/search_box_view.h"
11 #include "ui/app_list/views/tile_item_view.h" 13 #include "ui/app_list/views/tile_item_view.h"
12 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
13 #include "ui/views/background.h" 15 #include "ui/views/background.h"
14 #include "ui/views/border.h" 16 #include "ui/views/border.h"
15 #include "ui/views/layout/box_layout.h" 17 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/painter.h" 18 #include "ui/views/painter.h"
(...skipping 23 matching lines...) Expand all
40 view->width(), 42 view->width(),
41 view->height() - search_box_->y()), 43 view->height() - search_box_->y()),
42 SK_ColorWHITE); 44 SK_ColorWHITE);
43 } 45 }
44 46
45 views::View* search_box_; 47 views::View* search_box_;
46 scoped_ptr<views::Painter> painter_; 48 scoped_ptr<views::Painter> painter_;
47 DISALLOW_COPY_AND_ASSIGN(BottomHomeBackground); 49 DISALLOW_COPY_AND_ASSIGN(BottomHomeBackground);
48 }; 50 };
49 51
52 class AppListItemSearchResult : public app_list::SearchResult {
53 public:
54 explicit AppListItemSearchResult(app_list::AppListItem* item) : item_(item) {
55 set_display_type(app_list::SearchResult::DISPLAY_TILE);
56 SetIcon(item->icon());
57 set_title(base::UTF8ToUTF16(item->name()));
58 }
59 virtual ~AppListItemSearchResult() {}
60
61 virtual void Open(int event_flags) OVERRIDE {
62 item_->Activate(event_flags);
63 }
64 private:
65 app_list::AppListItem* item_;
66
67 DISALLOW_COPY_AND_ASSIGN(AppListItemSearchResult);
68 };
69
50 } // namespace 70 } // namespace
51 71
52 namespace athena { 72 namespace athena {
53 73
54 BottomHomeView::BottomHomeView(app_list::AppListViewDelegate* view_delegate) 74 BottomHomeView::BottomHomeView(app_list::AppListViewDelegate* view_delegate)
55 : view_delegate_(view_delegate) { 75 : view_delegate_(view_delegate) {
56 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 76 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
57 77
58 app_list::AppListModel* model = view_delegate->GetModel(); 78 app_list::AppListItemList* top_level =
59 app_list::AppListItemList* top_level = model->top_level_item_list(); 79 view_delegate->GetModel()->top_level_item_list();
60 80
61 views::View* items_container = new views::View(); 81 views::View* items_container = new views::View();
62 AddChildView(items_container); 82 AddChildView(items_container);
63 83
64 views::BoxLayout* items_layout = new views::BoxLayout( 84 views::BoxLayout* items_layout = new views::BoxLayout(
65 views::BoxLayout::kHorizontal, 0, 0, 0); 85 views::BoxLayout::kHorizontal, 0, 0, 0);
66 items_layout->SetDefaultFlex(1); 86 items_layout->SetDefaultFlex(1);
67 items_container->SetLayoutManager(items_layout); 87 items_container->SetLayoutManager(items_layout);
68 for (size_t i = 0; i < top_level->item_count(); ++i) { 88 for (size_t i = 0; i < top_level->item_count(); ++i) {
69 app_list::TileItemView* tile_item_view = new app_list::TileItemView(); 89 app_list::TileItemView* tile_item_view = new app_list::TileItemView();
70 tile_item_view->SetAppListItem(top_level->item_at(i)); 90 app_list::SearchResult* result =
91 new AppListItemSearchResult(top_level->item_at(i));
92 app_list_item_search_results_.push_back(result);
93 tile_item_view->SetSearchResult(result);
71 items_container->AddChildView(tile_item_view); 94 items_container->AddChildView(tile_item_view);
72 tile_item_view->set_background(NULL); 95 tile_item_view->set_background(NULL);
73 } 96 }
74 97
75 app_list::SearchBoxView* search_box = new app_list::SearchBoxView( 98 app_list::SearchBoxView* search_box = new app_list::SearchBoxView(
76 this, view_delegate); 99 this, view_delegate);
77 AddChildView(search_box); 100 AddChildView(search_box);
78 search_box->SetBorder( 101 search_box->SetBorder(
79 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorGRAY)); 102 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorGRAY));
80 103
81 set_background(new BottomHomeBackground(search_box)); 104 set_background(new BottomHomeBackground(search_box));
82 } 105 }
83 106
84 BottomHomeView::~BottomHomeView() {} 107 BottomHomeView::~BottomHomeView() {}
85 108
86 void BottomHomeView::QueryChanged(app_list::SearchBoxView* sender) { 109 void BottomHomeView::QueryChanged(app_list::SearchBoxView* sender) {
87 // Nothing needs to be done. 110 // Nothing needs to be done.
88 } 111 }
89 112
90 } // namespace athena 113 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698