OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 canvas->DrawPath(arrow, stroke_paint); | 145 canvas->DrawPath(arrow, stroke_paint); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 // This class handles layout for the first row of a SuggestionView. | 149 // This class handles layout for the first row of a SuggestionView. |
150 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that | 150 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that |
151 // the former doesn't fully respect child visibility, and that the latter won't | 151 // the former doesn't fully respect child visibility, and that the latter won't |
152 // expand a single child). | 152 // expand a single child). |
153 class SectionRowView : public views::View { | 153 class SectionRowView : public views::View { |
154 public: | 154 public: |
155 SectionRowView() {} | 155 SectionRowView() { |
| 156 set_border(views::Border::CreateEmptyBorder(10, 0, 0, 0)); |
| 157 } |
| 158 |
156 virtual ~SectionRowView() {} | 159 virtual ~SectionRowView() {} |
157 | 160 |
158 // views::View implementation: | 161 // views::View implementation: |
159 virtual gfx::Size GetPreferredSize() OVERRIDE { | 162 virtual gfx::Size GetPreferredSize() OVERRIDE { |
160 int height = 0; | 163 int height = 0; |
161 int width = 0; | 164 int width = 0; |
162 for (int i = 0; i < child_count(); ++i) { | 165 for (int i = 0; i < child_count(); ++i) { |
163 if (child_at(i)->visible()) { | 166 if (child_at(i)->visible()) { |
164 if (width > 0) | 167 if (width > 0) |
165 width += kAroundTextPadding; | 168 width += kAroundTextPadding; |
166 | 169 |
167 gfx::Size size = child_at(i)->GetPreferredSize(); | 170 gfx::Size size = child_at(i)->GetPreferredSize(); |
168 height = std::max(height, size.height()); | 171 height = std::max(height, size.height()); |
169 width += size.width(); | 172 width += size.width(); |
170 } | 173 } |
171 } | 174 } |
172 | 175 |
173 return gfx::Size(width, height); | 176 gfx::Insets insets = GetInsets(); |
| 177 return gfx::Size(width + insets.width(), height + insets.height()); |
174 } | 178 } |
175 | 179 |
176 virtual void Layout() OVERRIDE { | 180 virtual void Layout() OVERRIDE { |
177 const gfx::Rect bounds = GetContentsBounds(); | 181 const gfx::Rect bounds = GetContentsBounds(); |
178 | 182 |
179 // Icon is left aligned. | 183 // Icon is left aligned. |
180 int start_x = bounds.x(); | 184 int start_x = bounds.x(); |
181 views::View* icon = child_at(0); | 185 views::View* icon = child_at(0); |
182 if (icon->visible()) { | 186 if (icon->visible()) { |
183 icon->SizeToPreferredSize(); | 187 icon->SizeToPreferredSize(); |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 SectionRowView* label_container = new SectionRowView(); | 1063 SectionRowView* label_container = new SectionRowView(); |
1060 AddChildView(label_container); | 1064 AddChildView(label_container); |
1061 | 1065 |
1062 // Label and icon. | 1066 // Label and icon. |
1063 label_container->AddChildView(icon_); | 1067 label_container->AddChildView(icon_); |
1064 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1068 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1065 label_container->AddChildView(label_); | 1069 label_container->AddChildView(label_); |
1066 | 1070 |
1067 // TODO(estade): get the sizing and spacing right on this textfield. | 1071 // TODO(estade): get the sizing and spacing right on this textfield. |
1068 decorated_->SetVisible(false); | 1072 decorated_->SetVisible(false); |
1069 decorated_->set_default_width_in_chars(10); | 1073 decorated_->set_default_width_in_chars(15); |
1070 label_container->AddChildView(decorated_); | 1074 label_container->AddChildView(decorated_); |
1071 | 1075 |
1072 // TODO(estade): need to get the line height right. | 1076 // TODO(estade): need to get the line height right. |
1073 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1077 label_line_2_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1074 label_line_2_->SetVisible(false); | 1078 label_line_2_->SetVisible(false); |
1075 label_line_2_->SetMultiLine(true); | 1079 label_line_2_->SetMultiLine(true); |
1076 AddChildView(label_line_2_); | 1080 AddChildView(label_line_2_); |
1077 | 1081 |
1078 // TODO(estade): do something about this '2'. | 1082 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
1079 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 2, 0)); | |
1080 } | 1083 } |
1081 | 1084 |
1082 AutofillDialogViews::SuggestionView::~SuggestionView() {} | 1085 AutofillDialogViews::SuggestionView::~SuggestionView() {} |
1083 | 1086 |
1084 gfx::Size AutofillDialogViews::SuggestionView::GetPreferredSize() { | 1087 gfx::Size AutofillDialogViews::SuggestionView::GetPreferredSize() { |
1085 // There's no preferred width. The parent's layout should get the preferred | 1088 // There's no preferred width. The parent's layout should get the preferred |
1086 // height from GetHeightForWidth(). | 1089 // height from GetHeightForWidth(). |
1087 return gfx::Size(); | 1090 return gfx::Size(); |
1088 } | 1091 } |
1089 | 1092 |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2423 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2421 : section(section), | 2424 : section(section), |
2422 container(NULL), | 2425 container(NULL), |
2423 manual_input(NULL), | 2426 manual_input(NULL), |
2424 suggested_info(NULL), | 2427 suggested_info(NULL), |
2425 suggested_button(NULL) {} | 2428 suggested_button(NULL) {} |
2426 | 2429 |
2427 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2430 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2428 | 2431 |
2429 } // namespace autofill | 2432 } // namespace autofill |
OLD | NEW |