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

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: address commnets 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
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/app_list/views/search_box_view.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/views/controls/button/custom_button.h"
13 #include "ui/views/controls/webview/webview.h"
14 #include "ui/views/layout/box_layout.h"
15
16 namespace app_list {
17
18 namespace {
19
20 const int kTopMargin = 20;
21
22 const int kWebViewWidth = 200;
23 const int kWebViewHeight = 95;
24
25 const int kInstantContainerSpacing = 15;
26 const int kFakeBarWidth = 350;
27 const int kFakeBarHeight = 30;
28
29 // A button that is the placeholder for the search bar in the start page view.
30 class BarPlaceholderButton : public views::CustomButton {
31 public:
32 explicit BarPlaceholderButton(views::ButtonListener* listener)
33 : views::CustomButton(listener) {}
34
35 virtual ~BarPlaceholderButton() {}
36
37 // Overridden from views::View:
38 virtual gfx::Size GetPreferredSize() OVERRIDE {
39 return gfx::Size(kFakeBarWidth, kFakeBarHeight);
40 }
41
42 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
43 PaintButton(
44 canvas,
45 state() == STATE_HOVERED ? kPagerHoverColor : kPagerNormalColor);
46 }
47
48 private:
49 // Paints a rectangular button.
50 void PaintButton(gfx::Canvas* canvas, SkColor base_color) {
51 gfx::Rect rect(GetContentsBounds());
52 rect.ClampToCenteredSize(gfx::Size(kFakeBarWidth, kFakeBarHeight));
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 items_container_(new views::View) {
tapted 2014/05/08 08:19:50 is this used? (stray?)
calamity 2014/05/08 08:31:31 Done.
71 AddChildView(instant_container_);
72 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
73 instant_container_->SetLayoutManager(new views::BoxLayout(
74 views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing));
75
76 views::WebView* web_view =
77 new views::WebView(start_page_web_contents->GetBrowserContext());
78 web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight));
79 web_view->SetWebContents(start_page_web_contents);
80
81 instant_container_->AddChildView(web_view);
82 instant_container_->AddChildView(new BarPlaceholderButton(this));
83 }
84
85 StartPageView::~StartPageView() {
86 }
87
88 void StartPageView::Reset() {
89 instant_container_->SetVisible(true);
90 }
91
92 void StartPageView::ButtonPressed(views::Button* sender,
93 const ui::Event& event) {
94 app_list_main_view_->search_box_view()->SetVisible(true);
95 app_list_main_view_->search_box_view()->RequestFocus();
96 instant_container_->SetVisible(false);
97 }
98
99 } // namespace app_list
OLDNEW
« ui/app_list/views/contents_view.cc ('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