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 61037f73a2ab4c9a0a580ac92168d97a4d67ad87..7cff74e209e108213813c00cc7b836fd3cc266d4 100644 |
--- a/ui/app_list/views/start_page_view.cc |
+++ b/ui/app_list/views/start_page_view.cc |
@@ -4,11 +4,18 @@ |
#include "ui/app_list/views/start_page_view.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "content/public/browser/web_contents.h" |
#include "ui/app_list/app_list_constants.h" |
+#include "ui/app_list/app_list_item.h" |
+#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/tile_item_view.h" |
#include "ui/gfx/canvas.h" |
#include "ui/views/controls/button/custom_button.h" |
+#include "ui/views/controls/image_view.h" |
+#include "ui/views/controls/label.h" |
#include "ui/views/controls/webview/webview.h" |
#include "ui/views/layout/box_layout.h" |
@@ -16,15 +23,18 @@ namespace app_list { |
namespace { |
-const int kTopMargin = 20; |
+const int kTopMargin = 30; |
const int kWebViewWidth = 200; |
-const int kWebViewHeight = 95; |
+const int kWebViewHeight = 105; |
-const int kInstantContainerSpacing = 15; |
-const int kBarPlaceholderWidth = 350; |
+const int kInstantContainerSpacing = 20; |
+const int kBarPlaceholderWidth = 490; |
const int kBarPlaceholderHeight = 30; |
+const size_t kNumStartPageTiles = 5; |
+const int kTileSpacing = 10; |
+ |
// A button that is the placeholder for the search bar in the start page view. |
class BarPlaceholderButton : public views::CustomButton { |
public: |
@@ -64,14 +74,25 @@ class BarPlaceholderButton : public views::CustomButton { |
} // namespace |
StartPageView::StartPageView(AppListMainView* app_list_main_view, |
- content::WebContents* start_page_web_contents) |
+ AppListViewDelegate* view_delegate) |
: app_list_main_view_(app_list_main_view), |
- instant_container_(new views::View) { |
- AddChildView(instant_container_); |
- SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
- instant_container_->SetLayoutManager(new views::BoxLayout( |
+ model_(NULL), |
+ view_delegate_(view_delegate), |
+ instant_container_(new views::View), |
+ tiles_container_(new views::View) { |
+ SetLayoutManager(new views::BoxLayout( |
views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing)); |
+ // 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_main_axis_alignment( |
+ views::BoxLayout::MAIN_AXIS_ALIGNMENT_END); |
+ instant_container_->SetLayoutManager(instant_layout_manager); |
+ |
+ content::WebContents* start_page_web_contents = |
+ view_delegate->GetStartPageContents(); |
views::WebView* web_view = new views::WebView( |
start_page_web_contents ? start_page_web_contents->GetBrowserContext() |
: NULL); |
@@ -80,13 +101,50 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view, |
instant_container_->AddChildView(web_view); |
instant_container_->AddChildView(new BarPlaceholderButton(this)); |
+ |
+ // The view containing the start page tiles. |
+ AddChildView(tiles_container_); |
+ views::BoxLayout* tiles_layout_manager = |
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kTileSpacing); |
+ tiles_layout_manager->set_main_axis_alignment( |
+ views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
+ tiles_container_->SetLayoutManager(tiles_layout_manager); |
+ for (size_t i = 0; i < kNumStartPageTiles; ++i) { |
+ TileItemView* tile_item = new TileItemView(); |
+ tiles_container_->AddChildView(tile_item); |
+ tile_views_.push_back(tile_item); |
+ } |
+ |
+ SetModel(view_delegate_->GetModel()); |
+ view_delegate_->AddObserver(this); |
} |
StartPageView::~StartPageView() { |
+ view_delegate_->RemoveObserver(this); |
+} |
+ |
+void StartPageView::SetModel(AppListModel* model) { |
+ DCHECK(model); |
+ if (model_) |
+ model_->RemoveObserver(this); |
+ model_ = model; |
+ model_->AddObserver(this); |
+ Reset(); |
} |
void StartPageView::Reset() { |
instant_container_->SetVisible(true); |
+ if (!model_ || !model_->top_level_item_list()) |
+ return; |
+ |
+ for (size_t i = 0; i < kNumStartPageTiles; ++i) { |
+ AppListItem* item = NULL; |
+ if (i < model_->top_level_item_list()->item_count()) |
+ item = model_->top_level_item_list()->item_at(i); |
+ tile_views_[i]->SetAppListItem(item); |
+ } |
+ |
+ Layout(); |
} |
void StartPageView::ButtonPressed(views::Button* sender, |
@@ -95,4 +153,24 @@ void StartPageView::ButtonPressed(views::Button* sender, |
instant_container_->SetVisible(false); |
} |
+void StartPageView::OnProfilesChanged() { |
+ SetModel(view_delegate_->GetModel()); |
+} |
+ |
+void StartPageView::OnAppListModelStatusChanged() { |
+ Reset(); |
+} |
+ |
+void StartPageView::OnAppListItemAdded(AppListItem* item) { |
+ Reset(); |
+} |
+ |
+void StartPageView::OnAppListItemDeleted() { |
+ Reset(); |
+} |
+ |
+void StartPageView::OnAppListItemUpdated(AppListItem* item) { |
+ Reset(); |
+} |
+ |
} // namespace app_list |