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

Side by Side Diff: ui/app_list/views/contents_switcher_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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/contents_switcher_view.h" 5 #include "ui/app_list/views/contents_switcher_view.h"
6 6
7 #include "ui/app_list/app_list_constants.h" 7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/views/contents_view.h" 8 #include "ui/app_list/views/contents_view.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/controls/button/custom_button.h" 10 #include "ui/views/controls/button/custom_button.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view) 62 ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view)
63 : contents_view_(contents_view), buttons_(new views::View) { 63 : contents_view_(contents_view), buttons_(new views::View) {
64 AddChildView(buttons_); 64 AddChildView(buttons_);
65 65
66 buttons_->SetLayoutManager(new views::BoxLayout( 66 buttons_->SetLayoutManager(new views::BoxLayout(
67 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); 67 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing));
68 buttons_->AddChildView( 68 buttons_->AddChildView(
69 new ContentsSwitcherButton(this, ContentsView::SHOW_APPS)); 69 new ContentsSwitcherButton(this, ContentsView::SHOW_APPS));
70 buttons_->AddChildView( 70 buttons_->AddChildView(
71 new ContentsSwitcherButton(this, ContentsView::SHOW_START_PAGE));
72 buttons_->AddChildView(
71 new ContentsSwitcherButton(this, ContentsView::SHOW_SEARCH_RESULTS)); 73 new ContentsSwitcherButton(this, ContentsView::SHOW_SEARCH_RESULTS));
72 } 74 }
73 75
74 ContentsSwitcherView::~ContentsSwitcherView() {} 76 ContentsSwitcherView::~ContentsSwitcherView() {}
75 77
76 gfx::Size ContentsSwitcherView::GetPreferredSize() { 78 gfx::Size ContentsSwitcherView::GetPreferredSize() {
77 return gfx::Size(buttons_->GetPreferredSize().width(), kPreferredHeight); 79 return gfx::Size(buttons_->GetPreferredSize().width(), kPreferredHeight);
78 } 80 }
79 81
80 void ContentsSwitcherView::Layout() { 82 void ContentsSwitcherView::Layout() {
81 gfx::Rect rect(GetContentsBounds()); 83 gfx::Rect rect(GetContentsBounds());
82 84
83 // Makes |buttons_| horizontally center and vertically fill. 85 // Makes |buttons_| horizontally center and vertically fill.
84 gfx::Size buttons_size(buttons_->GetPreferredSize()); 86 gfx::Size buttons_size(buttons_->GetPreferredSize());
85 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2, 87 gfx::Rect buttons_bounds(rect.CenterPoint().x() - buttons_size.width() / 2,
86 rect.y(), 88 rect.y(),
87 buttons_size.width(), 89 buttons_size.width(),
88 rect.height()); 90 rect.height());
89 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds)); 91 buttons_->SetBoundsRect(gfx::IntersectRects(rect, buttons_bounds));
90 } 92 }
91 93
92 void ContentsSwitcherView::ButtonPressed(views::Button* sender, 94 void ContentsSwitcherView::ButtonPressed(views::Button* sender,
93 const ui::Event& event) { 95 const ui::Event& event) {
94 contents_view_->SetShowState( 96 contents_view_->SetShowState(
95 static_cast<ContentsView::ShowState>(sender->tag())); 97 static_cast<ContentsView::ShowState>(sender->tag()));
96 } 98 }
97 99
98 } // namespace app_list 100 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698