Commit fb919714 authored by finnur@chromium.org's avatar finnur@chromium.org

Polish for Extension Install Dialog.

- Make sure the bullet is on its own column so that the text that follows doesn't wrap directly under the bullet.
- Add a bit of horizontal padding for the expandable details.
- Make sure the Up/Down arrow is always in the same place so that it doesn't shift horizontally when toggled.

BUG=278328
R=sky@chromium.org

Review URL: https://codereview.chromium.org/23890009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222033 0039d316-1c4b-4281-b951-d872f2087c98
parent 6fb79a31
...@@ -163,6 +163,36 @@ class ExtensionInstallDialogView : public views::DialogDelegateView, ...@@ -163,6 +163,36 @@ class ExtensionInstallDialogView : public views::DialogDelegateView,
DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView); DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView);
}; };
// 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);
column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING,
0,
views::GridLayout::USE_PREF,
0, // no fixed width
0);
column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING,
0,
views::GridLayout::USE_PREF,
0, // no fixed width
0);
layout->StartRow(0, 0);
layout->AddView(new views::Label(PrepareForDisplay(string16(), true)));
layout->AddView(view);
}
// A view to display text with an expandable details section. // A view to display text with an expandable details section.
class ExpandableContainerView : public views::View, class ExpandableContainerView : public views::View,
public views::ButtonListener, public views::ButtonListener,
...@@ -173,7 +203,7 @@ class ExpandableContainerView : public views::View, ...@@ -173,7 +203,7 @@ class ExpandableContainerView : public views::View,
const string16& description, const string16& description,
const PermissionDetails& details, const PermissionDetails& details,
int horizontal_space, int horizontal_space,
bool show_bullets); bool parent_bulleted);
virtual ~ExpandableContainerView(); virtual ~ExpandableContainerView();
// views::View: // views::View:
...@@ -194,7 +224,7 @@ class ExpandableContainerView : public views::View, ...@@ -194,7 +224,7 @@ class ExpandableContainerView : public views::View,
// A view which displays all the details of an IssueAdviceInfoEntry. // A view which displays all the details of an IssueAdviceInfoEntry.
class DetailsView : public views::View { class DetailsView : public views::View {
public: public:
explicit DetailsView(int horizontal_space, bool show_bullets); explicit DetailsView(int horizontal_space, bool parent_bulleted);
virtual ~DetailsView() {} virtual ~DetailsView() {}
// views::View: // views::View:
...@@ -209,8 +239,9 @@ class ExpandableContainerView : public views::View, ...@@ -209,8 +239,9 @@ class ExpandableContainerView : public views::View,
views::GridLayout* layout_; views::GridLayout* layout_;
double state_; double state_;
// Whether to show bullets in front of each item in the details. // Whether the parent item is showing bullets. This will determine how much
bool show_bullets_; // extra indentation is needed.
bool parent_bulleted_;
DISALLOW_COPY_AND_ASSIGN(DetailsView); DISALLOW_COPY_AND_ASSIGN(DetailsView);
}; };
...@@ -481,12 +512,12 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( ...@@ -481,12 +512,12 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) {
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
views::Label* permission_label = new views::Label(PrepareForDisplay( views::Label* permission_label =
prompt.GetPermission(i), true)); new views::Label(prompt.GetPermission(i));
permission_label->SetMultiLine(true); permission_label->SetMultiLine(true);
permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
permission_label->SizeToFit(left_column_width); permission_label->SizeToFit(left_column_width);
layout->AddView(permission_label); layout->AddView(new BulletedView(permission_label));
// If we have more details to provide, show them in collapsed form. // If we have more details to provide, show them in collapsed form.
if (!prompt.GetPermissionsDetails(i).empty()) { if (!prompt.GetPermissionsDetails(i).empty()) {
...@@ -496,7 +527,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( ...@@ -496,7 +527,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
PrepareForDisplay(prompt.GetPermissionsDetails(i), false)); PrepareForDisplay(prompt.GetPermissionsDetails(i), false));
ExpandableContainerView* details_container = ExpandableContainerView* details_container =
new ExpandableContainerView( new ExpandableContainerView(
this, string16(), details, left_column_width, false); this, string16(), details, left_column_width, true);
layout->AddView(details_container); layout->AddView(details_container);
} }
} }
...@@ -548,7 +579,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( ...@@ -548,7 +579,7 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
details.push_back(entry.details[x]); details.push_back(entry.details[x]);
ExpandableContainerView* issue_advice_view = ExpandableContainerView* issue_advice_view =
new ExpandableContainerView( new ExpandableContainerView(
this, entry.description, details, space_for_oauth, false); this, entry.description, details, space_for_oauth, true);
layout->AddView(issue_advice_view); layout->AddView(issue_advice_view);
} }
} }
...@@ -677,13 +708,18 @@ ExtensionInstallPrompt::GetDefaultShowDialogCallback() { ...@@ -677,13 +708,18 @@ ExtensionInstallPrompt::GetDefaultShowDialogCallback() {
// ExpandableContainerView::DetailsView ---------------------------------------- // ExpandableContainerView::DetailsView ----------------------------------------
ExpandableContainerView::DetailsView::DetailsView(int horizontal_space, ExpandableContainerView::DetailsView::DetailsView(int horizontal_space,
bool show_bullets) bool parent_bulleted)
: layout_(new views::GridLayout(this)), : layout_(new views::GridLayout(this)),
state_(0), state_(0),
show_bullets_(show_bullets) { parent_bulleted_(parent_bulleted) {
SetLayoutManager(layout_); SetLayoutManager(layout_);
views::ColumnSet* column_set = layout_->AddColumnSet(0); views::ColumnSet* column_set = layout_->AddColumnSet(0);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); // If the parent is using bullets for its items, then a padding of one unit
// will make the child item (which has no bullet) look like a sibling of its
// parent. Therefore increase the indentation by one more unit to show that it
// is in fact a child item (with no missing bullet) and not a sibling.
column_set->AddPaddingColumn(
0, views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1));
column_set->AddColumn(views::GridLayout::LEADING, column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING, views::GridLayout::LEADING,
0, 0,
...@@ -696,7 +732,7 @@ void ExpandableContainerView::DetailsView::AddDetail(const string16& detail) { ...@@ -696,7 +732,7 @@ void ExpandableContainerView::DetailsView::AddDetail(const string16& detail) {
layout_->StartRowWithPadding(0, 0, layout_->StartRowWithPadding(0, 0,
0, views::kRelatedControlSmallVerticalSpacing); 0, views::kRelatedControlSmallVerticalSpacing);
views::Label* detail_label = views::Label* detail_label =
new views::Label(PrepareForDisplay(detail, show_bullets_)); new views::Label(PrepareForDisplay(detail, false));
detail_label->SetMultiLine(true); detail_label->SetMultiLine(true);
detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout_->AddView(detail_label); layout_->AddView(detail_label);
...@@ -720,7 +756,7 @@ ExpandableContainerView::ExpandableContainerView( ...@@ -720,7 +756,7 @@ ExpandableContainerView::ExpandableContainerView(
const string16& description, const string16& description,
const PermissionDetails& details, const PermissionDetails& details,
int horizontal_space, int horizontal_space,
bool show_bullets) bool parent_bulleted)
: owner_(owner), : owner_(owner),
details_view_(NULL), details_view_(NULL),
arrow_view_(NULL), arrow_view_(NULL),
...@@ -739,18 +775,17 @@ ExpandableContainerView::ExpandableContainerView( ...@@ -739,18 +775,17 @@ ExpandableContainerView::ExpandableContainerView(
if (!description.empty()) { if (!description.empty()) {
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
views::Label* description_label = views::Label* description_label = new views::Label(description);
new views::Label(PrepareForDisplay(description, true));
description_label->SetMultiLine(true); description_label->SetMultiLine(true);
description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
description_label->SizeToFit(horizontal_space); description_label->SizeToFit(horizontal_space);
layout->AddView(description_label); layout->AddView(new BulletedView(description_label));
} }
if (details.empty()) if (details.empty())
return; return;
details_view_ = new DetailsView(horizontal_space, show_bullets); details_view_ = new DetailsView(horizontal_space, parent_bulleted);
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
layout->AddView(details_view_); layout->AddView(details_view_);
...@@ -758,33 +793,44 @@ ExpandableContainerView::ExpandableContainerView( ...@@ -758,33 +793,44 @@ ExpandableContainerView::ExpandableContainerView(
for (size_t i = 0; i < details.size(); ++i) for (size_t i = 0; i < details.size(); ++i)
details_view_->AddDetail(details[i]); details_view_->AddDetail(details[i]);
// Prepare the columns for the More Details row. views::Link* link = new views::Link(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS));
// Make sure the link width column is as wide as needed for both Show and
// Hide details, so that the arrow doesn't shift horizontally when we toggle.
int link_col_width =
views::kRelatedControlHorizontalSpacing +
std::max(link->font_list().GetStringWidth(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS)),
link->font_list().GetStringWidth(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)));
column_set = layout->AddColumnSet(++column_set_id); column_set = layout->AddColumnSet(++column_set_id);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); // Padding to the left of the More Details column. If the parent is using
// bullets for its items, then a padding of one unit will make the child item
// (which has no bullet) look like a sibling of its parent. Therefore increase
// the indentation by one more unit to show that it is in fact a child item
// (with no missing bullet) and not a sibling.
column_set->AddPaddingColumn(
0, views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1));
// The More Details column.
column_set->AddColumn(views::GridLayout::LEADING, column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING, views::GridLayout::LEADING,
0, 0,
views::GridLayout::USE_PREF, views::GridLayout::FIXED,
0, link_col_width,
0); link_col_width);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); // The Up/Down arrow column.
column_set->AddColumn(views::GridLayout::LEADING, column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING, views::GridLayout::LEADING,
0, 0,
views::GridLayout::USE_PREF, views::GridLayout::USE_PREF,
0, 0,
0); 0);
column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING,
0,
views::GridLayout::USE_PREF,
0,
0);
// Add the More Details link. // Add the More Details link.
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
more_details_ = new views::Link( more_details_ = link;
l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS));
more_details_->set_listener(this); more_details_->set_listener(this);
more_details_->SetHorizontalAlignment(gfx::ALIGN_LEFT); more_details_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->AddView(more_details_); layout->AddView(more_details_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment