Index: ash/app_list/app_list_view.cc |
diff --git a/ash/app_list/app_list_view.cc b/ash/app_list/app_list_view.cc |
index 9aa341085838ab3703a66c724e08695cf47ae6e3..e6b5d1b7eafcb3de8d41192e498782239ca06e69 100644 |
--- a/ash/app_list/app_list_view.cc |
+++ b/ash/app_list/app_list_view.cc |
@@ -4,22 +4,24 @@ |
#include "ash/app_list/app_list_view.h" |
-#include "ash/app_list/app_list_groups_view.h" |
#include "ash/app_list/app_list_item_view.h" |
#include "ash/app_list/app_list_model.h" |
+#include "ash/app_list/app_list_model_view.h" |
#include "ash/app_list/app_list_view_delegate.h" |
+#include "ash/app_list/search_box_view.h" |
#include "ash/shell.h" |
-#include "ui/views/layout/fill_layout.h" |
+#include "ui/views/controls/textfield/textfield.h" |
#include "ui/views/widget/widget.h" |
namespace ash { |
AppListView::AppListView( |
- AppListModel* model, |
AppListViewDelegate* delegate, |
const gfx::Rect& bounds) |
- : model_(model), |
- delegate_(delegate) { |
+ : model_(new AppListModel), |
+ delegate_(delegate), |
+ search_box_view_(NULL), |
+ model_view_(NULL) { |
Init(bounds); |
} |
@@ -32,9 +34,10 @@ void AppListView::Close() { |
} |
void AppListView::Init(const gfx::Rect& bounds) { |
- SetLayoutManager(new views::FillLayout); |
- AppListGroupsView* groups_view = new AppListGroupsView(model_.get(), this); |
- AddChildView(groups_view); |
+ search_box_view_ = new SearchBoxView; |
+ AddChildView(search_box_view_); |
+ model_view_ = new AppListModelView(model_.get(), this); |
+ AddChildView(model_view_); |
views::Widget::InitParams widget_params( |
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
@@ -47,8 +50,38 @@ void AppListView::Init(const gfx::Rect& bounds) { |
widget->Init(widget_params); |
widget->SetContentsView(this); |
- if (groups_view->GetFocusedTile()) |
- groups_view->GetFocusedTile()->RequestFocus(); |
+ UpdateModel(); |
+} |
+ |
+void AppListView::UpdateModel() { |
+ if (delegate_.get()) |
+ delegate_->BuildAppListModel(search_box_view_->search_text(), model_.get()); |
+} |
+ |
+views::View* AppListView::GetInitiallyFocusedView() { |
+ return search_box_view_->search_box(); |
+} |
+ |
+void AppListView::Layout() { |
+ gfx::Rect rect(GetContentsBounds()); |
+ |
+ const int kSectionPadding = 20; |
+ |
+ const int kSearchBoxContainerHeight = 60; |
+ const int kSearchBoxHeight = 48; |
+ const int kSearchBoxWidth = 640; |
+ |
+ gfx::Rect search_box_frame(rect); |
+ search_box_frame.set_height(kSearchBoxContainerHeight); |
+ search_box_view_->SetBounds( |
+ search_box_frame.x(), |
+ search_box_frame.y() + (search_box_frame.height() - kSearchBoxHeight) / 2, |
+ kSearchBoxWidth, |
+ kSearchBoxHeight); |
+ |
+ gfx::Rect app_list_frame(rect); |
+ app_list_frame.set_y(search_box_frame.bottom() + kSectionPadding); |
+ model_view_->SetBoundsRect(app_list_frame); |
} |
bool AppListView::OnKeyPressed(const views::KeyEvent& event) { |
@@ -67,10 +100,13 @@ bool AppListView::OnMousePressed(const views::MouseEvent& event) { |
return true; |
} |
-void AppListView::AppListItemActivated(AppListItemView* sender, |
- int event_flags) { |
- if (delegate_.get()) |
- delegate_->OnAppListItemActivated(sender->model(), event_flags); |
+void AppListView::ButtonPressed(views::Button* sender, |
+ const views::Event& event) { |
+ if (delegate_.get()) { |
+ delegate_->OnAppListItemActivated( |
+ static_cast<AppListItemView*>(sender)->model(), |
+ event.flags()); |
+ } |
Close(); |
} |