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..cd971f3db964b73546ffa54e96652f36657a580f 100644 |
--- a/ash/app_list/app_list_view.cc |
+++ b/ash/app_list/app_list_view.cc |
@@ -4,22 +4,34 @@ |
#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/shell.h" |
-#include "ui/views/layout/fill_layout.h" |
+#include "ui/gfx/screen.h" |
+#include "ui/views/background.h" |
+#include "ui/views/controls/textfield/textfield.h" |
#include "ui/views/widget/widget.h" |
namespace ash { |
+namespace { |
+ |
+// Margins in pixels from screen edges. |
+const int kMargin = 50; |
+ |
+// 0.4 black |
+const SkColor kBackgroundColor = SkColorSetARGB(0x66, 0, 0, 0); |
+ |
+} // namespace |
+ |
AppListView::AppListView( |
- AppListModel* model, |
AppListViewDelegate* delegate, |
const gfx::Rect& bounds) |
- : model_(model), |
- delegate_(delegate) { |
+ : delegate_(delegate), |
+ model_view_(NULL) { |
+ set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
Init(bounds); |
} |
@@ -32,13 +44,11 @@ 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); |
+ model_view_ = new AppListModelView(this); |
+ AddChildView(model_view_); |
views::Widget::InitParams widget_params( |
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
- widget_params.bounds = bounds; |
widget_params.delegate = this; |
widget_params.keep_on_top = true; |
widget_params.transparent = true; |
@@ -46,9 +56,35 @@ void AppListView::Init(const gfx::Rect& bounds) { |
views::Widget* widget = new views::Widget; |
widget->Init(widget_params); |
widget->SetContentsView(this); |
+ widget->SetBounds(bounds); |
+ |
+ UpdateModel(); |
+} |
+ |
+void AppListView::UpdateModel() { |
+ if (delegate_.get()) { |
+ scoped_ptr<AppListModel> new_model(new AppListModel); |
+ delegate_->BuildAppListModel("", new_model.get()); |
sky
2012/03/01 00:26:57
"" -> std::string()
xiyuan
2012/03/01 19:58:47
Done.
|
+ model_view_->SetModel(new_model.get()); |
+ model_.reset(new_model.release()); |
+ } |
+} |
- if (groups_view->GetFocusedTile()) |
- groups_view->GetFocusedTile()->RequestFocus(); |
+views::View* AppListView::GetInitiallyFocusedView() { |
+ return model_view_; |
+} |
+ |
+void AppListView::Layout() { |
+ gfx::Rect rect(GetContentsBounds()); |
+ if (rect.IsEmpty()) |
+ return; |
+ |
+ gfx::Rect workarea_rect = gfx::Screen::GetMonitorWorkAreaNearestWindow( |
sky
2012/03/01 00:26:57
These aren't necessarily in the same coordinates.
xiyuan
2012/03/01 19:58:47
Done.
|
+ GetWidget()->GetNativeView()); |
+ |
+ rect.Inset(kMargin, kMargin); |
+ rect = rect.Intersect(workarea_rect); |
+ model_view_->SetBoundsRect(rect); |
} |
bool AppListView::OnKeyPressed(const views::KeyEvent& event) { |
@@ -67,10 +103,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(), |
sky
2012/03/01 00:26:57
This seems a bit fragile.
xiyuan
2012/03/01 19:58:47
Added a class name to AppListItemView to make sure
|
+ event.flags()); |
+ } |
Close(); |
} |