Update path of checkdeps to buildtools checkout
[chromium-blink-merge.git] / ui / app_list / views / signin_view.cc
blobde2faf1287b7b7225e2eed43c3561d4cc21771c0
1 // Copyright 2013 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.
5 #include "ui/app_list/views/signin_view.h"
7 #include "ui/app_list/signin_delegate.h"
8 #include "ui/gfx/font_list.h"
9 #include "ui/views/background.h"
10 #include "ui/views/controls/button/blue_button.h"
11 #include "ui/views/controls/label.h"
12 #include "ui/views/controls/link.h"
13 #include "ui/views/layout/grid_layout.h"
15 namespace {
17 const int kTopPadding = 40;
18 const int kBottomPadding = 40;
19 const int kLeftPadding = 40;
20 const int kRightPadding = 40;
21 const int kHeadingPadding = 30;
22 const int kButtonPadding = 40;
24 const int kTitleFontSize = 18;
25 const int kTextFontSize = 13;
26 const int kButtonFontSize = 12;
28 } // namespace
30 namespace app_list {
32 SigninView::SigninView(SigninDelegate* delegate, int width)
33 : delegate_(delegate) {
34 if (!delegate_)
35 return;
37 const gfx::FontList base_font_list;
38 const gfx::FontList& title_font_list = base_font_list.DeriveWithSizeDelta(
39 kTitleFontSize - base_font_list.GetFontSize());
40 const gfx::FontList& text_font_list = base_font_list.DeriveWithSizeDelta(
41 kTextFontSize - base_font_list.GetFontSize());
42 const gfx::FontList& button_font_list = base_font_list.DeriveWithSizeDelta(
43 kButtonFontSize - base_font_list.GetFontSize());
45 int title_descender =
46 title_font_list.GetHeight() - title_font_list.GetBaseline();
47 int text_descender =
48 text_font_list.GetHeight() - text_font_list.GetBaseline();
50 views::GridLayout* layout = new views::GridLayout(this);
51 layout->SetInsets(kTopPadding, kLeftPadding, kBottomPadding - text_descender,
52 kRightPadding);
53 SetLayoutManager(layout);
55 const int kNormalSetId = 0;
56 views::ColumnSet* columns = layout->AddColumnSet(kNormalSetId);
57 columns->AddColumn(views::GridLayout::FILL,
58 views::GridLayout::FILL,
60 views::GridLayout::USE_PREF,
62 0);
64 const int kButtonSetId = 1;
65 columns = layout->AddColumnSet(kButtonSetId);
66 columns->AddColumn(views::GridLayout::LEADING,
67 views::GridLayout::FILL,
69 views::GridLayout::USE_PREF,
71 0);
73 views::Label* heading = new views::Label(delegate_->GetSigninHeading());
74 heading->SetFontList(title_font_list);
75 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT);
77 layout->StartRow(0, kNormalSetId);
78 layout->AddView(heading);
80 views::Label* text = new views::Label(delegate_->GetSigninText());
81 text->SetFontList(text_font_list);
82 text->SetMultiLine(true);
83 text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
84 layout->StartRowWithPadding(0, kNormalSetId, 0,
85 kHeadingPadding - title_descender);
86 layout->AddView(text);
88 views::BlueButton* signin_button = new views::BlueButton(
89 this,
90 delegate_->GetSigninButtonText());
91 signin_button->SetFontList(button_font_list);
92 layout->StartRowWithPadding(0, kButtonSetId, 0,
93 kButtonPadding - text_descender);
94 layout->AddView(signin_button);
96 layout->StartRow(1, kNormalSetId);
97 learn_more_link_ = new views::Link(delegate_->GetLearnMoreLinkText());
98 learn_more_link_->set_listener(this);
99 learn_more_link_->SetFontList(text_font_list);
100 learn_more_link_->SetUnderline(false);
101 layout->AddView(learn_more_link_,
104 views::GridLayout::LEADING,
105 views::GridLayout::TRAILING);
107 layout->StartRow(0, kNormalSetId);
108 settings_link_ = new views::Link(delegate_->GetSettingsLinkText());
109 settings_link_->set_listener(this);
110 settings_link_->SetFontList(text_font_list);
111 settings_link_->SetUnderline(false);
112 layout->AddView(settings_link_,
115 views::GridLayout::LEADING,
116 views::GridLayout::TRAILING);
119 SigninView::~SigninView() {
122 void SigninView::ButtonPressed(views::Button* sender, const ui::Event& event) {
123 if (delegate_)
124 delegate_->ShowSignin();
127 void SigninView::LinkClicked(views::Link* source, int event_flags) {
128 if (delegate_) {
129 if (source == learn_more_link_)
130 delegate_->OpenLearnMore();
131 else if (source == settings_link_)
132 delegate_->OpenSettings();
133 else
134 NOTREACHED();
138 } // namespace app_list