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

Side by Side 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: fix initialization order Created 6 years, 7 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
« no previous file with comments | « ui/app_list/views/start_page_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/app_list/views/start_page_view.h"
6
7 #include "content/public/browser/web_contents.h"
8 #include "ui/app_list/app_list_constants.h"
9 #include "ui/app_list/views/app_list_main_view.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/views/controls/button/custom_button.h"
12 #include "ui/views/controls/webview/webview.h"
13 #include "ui/views/layout/box_layout.h"
14
15 namespace app_list {
16
17 namespace {
18
19 const int kTopMargin = 20;
20
21 const int kWebViewWidth = 200;
22 const int kWebViewHeight = 95;
23
24 const int kInstantContainerSpacing = 15;
25 const int kBarPlaceholderWidth = 350;
26 const int kBarPlaceholderHeight = 30;
27
28 // A button that is the placeholder for the search bar in the start page view.
29 class BarPlaceholderButton : public views::CustomButton {
30 public:
31 explicit BarPlaceholderButton(views::ButtonListener* listener)
32 : views::CustomButton(listener) {}
33
34 virtual ~BarPlaceholderButton() {}
35
36 // Overridden from views::View:
37 virtual gfx::Size GetPreferredSize() OVERRIDE {
38 return gfx::Size(kBarPlaceholderWidth, kBarPlaceholderHeight);
39 }
40
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
42 PaintButton(
43 canvas,
44 state() == STATE_HOVERED ? kPagerHoverColor : kPagerNormalColor);
45 }
46
47 private:
48 // Paints a rectangular button.
49 void PaintButton(gfx::Canvas* canvas, SkColor base_color) {
50 gfx::Rect rect(GetContentsBounds());
51 rect.ClampToCenteredSize(
52 gfx::Size(kBarPlaceholderWidth, kBarPlaceholderHeight));
53
54 SkPaint paint;
55 paint.setAntiAlias(true);
56 paint.setStyle(SkPaint::kFill_Style);
57 paint.setColor(base_color);
58 canvas->DrawRect(rect, paint);
59 }
60
61 DISALLOW_COPY_AND_ASSIGN(BarPlaceholderButton);
62 };
63
64 } // namespace
65
66 StartPageView::StartPageView(AppListMainView* app_list_main_view,
67 content::WebContents* start_page_web_contents)
68 : app_list_main_view_(app_list_main_view),
69 instant_container_(new views::View) {
70 AddChildView(instant_container_);
71 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
72 instant_container_->SetLayoutManager(new views::BoxLayout(
73 views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing));
74
75 views::WebView* web_view =
76 new views::WebView(start_page_web_contents->GetBrowserContext());
77 web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight));
78 web_view->SetWebContents(start_page_web_contents);
79
80 instant_container_->AddChildView(web_view);
81 instant_container_->AddChildView(new BarPlaceholderButton(this));
82 }
83
84 StartPageView::~StartPageView() {
85 }
86
87 void StartPageView::Reset() {
88 instant_container_->SetVisible(true);
89 }
90
91 void StartPageView::ButtonPressed(views::Button* sender,
92 const ui::Event& event) {
93 app_list_main_view_->OnStartPageSearchButtonPressed();
94 instant_container_->SetVisible(false);
95 }
96
97 } // namespace app_list
OLDNEW
« no previous file with comments | « 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