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

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

Issue 186483004: Add a skeleton Start Page to the experimental app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ares_change_experimental_animation
Patch Set: rework Created 6 years, 9 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
« ui/app_list/views/start_page_view.h ('K') | « 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
new file mode 100644
index 0000000000000000000000000000000000000000..642ecd773d4d507bc3f291ad2732b0b2689dbfca
--- /dev/null
+++ b/ui/app_list/views/start_page_view.cc
@@ -0,0 +1,104 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/app_list/views/start_page_view.h"
+
+#include "content/public/browser/web_contents.h"
+#include "ui/app_list/app_list_constants.h"
+#include "ui/app_list/views/app_list_main_view.h"
+#include "ui/app_list/views/search_box_view.h"
+#include "ui/gfx/canvas.h"
+#include "ui/views/controls/button/custom_button.h"
+#include "ui/views/controls/webview/webview.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace app_list {
+
+namespace {
+
+const int kTopMargin = 20;
+
+const int kWebViewWidth = 200;
+const int kWebViewHeight = 95;
+
+const int kInstantContainerSpacing = 15;
+const int kFakeBarWidth = 350;
+const int kFakeBarHeight = 30;
+
+class FakeBarButton : public views::CustomButton {
+ public:
+ explicit FakeBarButton(views::ButtonListener* listener)
+ : views::CustomButton(listener) {
+ }
+
+ virtual ~FakeBarButton() {}
+
+ // Overridden from views::View:
+ virtual gfx::Size GetPreferredSize() OVERRIDE {
+ return gfx::Size(kFakeBarWidth, kFakeBarHeight);
+ }
+
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ PaintButton(canvas, state() == STATE_HOVERED ? kPagerHoverColor
+ : kPagerNormalColor);
+ }
+
+ private:
+ // Paints a rectangular button.
+ void PaintButton(gfx::Canvas* canvas, SkColor base_color) {
+ gfx::Rect rect(GetContentsBounds());
+ rect.ClampToCenteredSize(gfx::Size(kFakeBarWidth, kFakeBarHeight));
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(base_color);
+ canvas->DrawRect(rect, paint);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(FakeBarButton);
+};
+
+} // namespace
+
+StartPageView::StartPageView(AppListMainView* app_list_main_view,
+ content::WebContents* start_page_web_contents)
+ : app_list_main_view_(app_list_main_view),
+ instant_container_(new views::View) {
+ AddChildView(instant_container_);
+ instant_container_->SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing));
+
+ views::WebView* web_view =
+ new views::WebView(start_page_web_contents->GetBrowserContext());
+ web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight));
+ web_view->SetWebContents(start_page_web_contents);
+
+ instant_container_->AddChildView(web_view);
+ instant_container_->AddChildView(new FakeBarButton(this));
+}
+
+StartPageView::~StartPageView() {
+}
+
+void StartPageView::Layout() {
+ gfx::Rect rect(GetContentsBounds());
+
+ // Makes |instant_container_| horizontally center and vertically fill.
+ gfx::Size instant_container_size(instant_container_->GetPreferredSize());
+ gfx::Rect top_half_bounds(
+ rect.CenterPoint().x() - instant_container_size.width() / 2,
+ rect.y(),
+ instant_container_size.width(),
+ rect.height() / 2);
+ instant_container_->SetBoundsRect(top_half_bounds);
+}
+
+void StartPageView::ButtonPressed(views::Button* sender,
+ const ui::Event& event) {
+ app_list_main_view_->search_box_view()->SetVisible(true);
+ app_list_main_view_->search_box_view()->RequestFocus();
+}
+
+} // namespace app_list
« ui/app_list/views/start_page_view.h ('K') | « 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