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

Unified Diff: chrome/browser/ui/views/sad_tab_view.cc

Issue 2794763002: New Sad Tab strings. (Closed)
Patch Set: final tweak from the denizens of UI review Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/sad_tab_view.cc
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc
index aeaa218893a6848b3db6169c8d8573266c9e9ed4..17fb0396b86a54c9e248a2cc4256716511d40bd9 100644
--- a/chrome/browser/ui/views/sad_tab_view.cc
+++ b/chrome/browser/ui/views/sad_tab_view.cc
@@ -30,6 +30,51 @@ namespace {
constexpr int kMaxContentWidth = 600;
constexpr int kMinColumnWidth = 120;
constexpr int kTitleBottomSpacing = 13;
+constexpr int kBulletBottomSpacing = 1;
+constexpr int kBulletWidth = 20;
+constexpr int kBulletPadding = 13;
+
+// A simple view that prepends a view with a bullet with the help of a grid
+// layout.
+class BulletedView : public views::View {
+ public:
+ explicit BulletedView(views::View* view);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BulletedView);
+};
+
+BulletedView::BulletedView(views::View* view) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+ views::ColumnSet* column_set = layout->AddColumnSet(0);
sky 2017/05/18 16:10:06 Creating another view will certainly work, but Gri
Will Harris 2017/05/18 17:13:29 Adding a new column set here means that I need to
+ column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING,
+ 0, views::GridLayout::FIXED, kBulletWidth, 0);
+ column_set->AddPaddingColumn(0, kBulletPadding);
+ column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING,
+ 0, views::GridLayout::USE_PREF,
+ 0, // No fixed width.
+ 0);
+ layout->StartRow(0, 0);
+ views::Label* bullet_label = new views::Label(L"\u2022");
+ bullet_label->SetEnabled(false);
+ bullet_label->SetLineHeight(views::kPanelSubVerticalSpacing);
+ bullet_label->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
+
+ layout->AddView(bullet_label);
+ layout->AddView(view);
+}
+
+views::Label* CreateFormattedLabel(int message_id) {
+ views::Label* label = new views::Label(l10n_util::GetStringUTF16(message_id));
+
+ label->SetMultiLine(true);
+ label->SetEnabled(false);
+ label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ label->SetLineHeight(views::kPanelSubVerticalSpacing);
+
+ return label;
+}
} // namespace
@@ -68,16 +113,22 @@ SadTabView::SadTabView(content::WebContents* web_contents,
views::kPanelVerticalSpacing);
layout->AddView(title_, 2, 1);
- message_ = new views::Label(l10n_util::GetStringUTF16(GetMessage()));
-
- message_->SetMultiLine(true);
- message_->SetEnabled(false);
- message_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- message_->SetLineHeight(views::kPanelSubVerticalSpacing);
-
+ views::Label* message = CreateFormattedLabel(GetMessage());
layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing);
- layout->AddView(message_, 2, 1, views::GridLayout::LEADING,
+ layout->AddView(message, 2, 1, views::GridLayout::LEADING,
views::GridLayout::LEADING);
+ labels_.push_back(message);
+ size_t bullet_id = 0;
+ int bullet_string_id = GetSubMessage(bullet_id);
+
+ while (bullet_string_id) {
+ message = CreateFormattedLabel(bullet_string_id);
+ layout->StartRowWithPadding(0, column_set_id, 0, kBulletBottomSpacing);
+ layout->AddView(new BulletedView(message), 2, 1, views::GridLayout::LEADING,
+ views::GridLayout::LEADING);
+ labels_.push_back(message);
+ bullet_string_id = GetSubMessage(++bullet_id);
+ }
action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
this, l10n_util::GetStringUTF16(GetButtonTitle()));
@@ -131,7 +182,9 @@ void SadTabView::Layout() {
// Specify the maximum message width explicitly.
const int max_width =
std::min(width() - views::kPanelSubVerticalSpacing * 2, kMaxContentWidth);
- message_->SizeToFit(max_width);
+ for (views::Label* label : labels_) {
+ label->SizeToFit(max_width);
+ }
title_->SizeToFit(max_width);
View::Layout();
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698