Commit e960d073 authored by meacer@chromium.org's avatar meacer@chromium.org

Put alert dialog text in a scroll view.

This CL puts the dialog text inside a scroll view so that very long texts don't hide the dialog buttons by making the dialog oversized.
I also removed SetIcon method which isn't used anywhere.

Screenshots:
https://drive.google.com/file/d/0B9q2eN9gDoUIbU9Wb2F0OS1QTjA/edit?usp=sharing (alert)
https://drive.google.com/file/d/0B9q2eN9gDoUIYnh4ZWdFTEJBYVk/edit?usp=sharing (confirm)
https://drive.google.com/file/d/0B9q2eN9gDoUIQlhBS083ZDdGUWM/edit?usp=sharing (prompt)

BUG=391583

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282978 0039d316-1c4b-4281-b951-d872f2087c98
parent 872b71fd
......@@ -12,10 +12,11 @@
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
......@@ -76,7 +77,6 @@ MessageBoxView::InitParams::~InitParams() {
MessageBoxView::MessageBoxView(const InitParams& params)
: prompt_field_(NULL),
icon_(NULL),
checkbox_(NULL),
link_(NULL),
message_width_(params.message_width) {
......@@ -93,14 +93,6 @@ bool MessageBoxView::IsCheckBoxSelected() {
return checkbox_ ? checkbox_->checked() : false;
}
void MessageBoxView::SetIcon(const gfx::ImageSkia& icon) {
if (!icon_)
icon_ = new ImageView();
icon_->SetImage(icon);
icon_->SetBounds(0, 0, icon.width(), icon.height());
ResetLayoutManager();
}
void MessageBoxView::SetCheckBoxLabel(const base::string16& label) {
if (!checkbox_)
checkbox_ = new Checkbox(label);
......@@ -209,20 +201,9 @@ void MessageBoxView::ResetLayoutManager() {
GridLayout* layout = GridLayout::CreatePanel(this);
SetLayoutManager(layout);
gfx::Size icon_size;
if (icon_)
icon_size = icon_->GetPreferredSize();
// Add the column set for the message displayed at the top of the dialog box.
// And an icon, if one has been set.
const int message_column_view_set_id = 0;
ColumnSet* column_set = layout->AddColumnSet(message_column_view_set_id);
if (icon_) {
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
GridLayout::FIXED, icon_size.width(),
icon_size.height());
column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing);
}
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::FIXED, message_width_, 0);
......@@ -230,24 +211,21 @@ void MessageBoxView::ResetLayoutManager() {
const int extra_column_view_set_id = 1;
if (prompt_field_ || checkbox_ || link_) {
column_set = layout->AddColumnSet(extra_column_view_set_id);
if (icon_) {
column_set->AddPaddingColumn(
0, icon_size.width() + kUnrelatedControlHorizontalSpacing);
}
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
}
for (size_t i = 0; i < message_labels_.size(); ++i) {
layout->StartRow(i, message_column_view_set_id);
if (icon_) {
if (i == 0)
layout->AddView(icon_);
else
layout->SkipColumns(1);
}
layout->AddView(message_labels_[i]);
}
const int kMaxScrollViewHeight = 600;
views::View* message_contents = new views::View();
message_contents->SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
for (size_t i = 0; i < message_labels_.size(); ++i)
message_contents->AddChildView(message_labels_[i]);
ScrollView* scroll_view = new views::ScrollView();
scroll_view->ClipHeightTo(0, kMaxScrollViewHeight);
scroll_view->SetContents(message_contents);
layout->StartRow(0, message_column_view_set_id);
layout->AddView(scroll_view);
if (prompt_field_) {
layout->AddPaddingRow(0, inter_row_vertical_spacing_);
......
......@@ -10,14 +10,9 @@
#include "base/strings/string16.h"
#include "ui/views/view.h"
namespace gfx {
class ImageSkia;
}
namespace views {
class Checkbox;
class ImageView;
class Label;
class Link;
class LinkListener;
......@@ -66,10 +61,6 @@ class VIEWS_EXPORT MessageBoxView : public View {
// the message box has no checkbox.)
bool IsCheckBoxSelected();
// Adds |icon| to the upper left of the message box or replaces the current
// icon. To start out, the message box has no icon.
void SetIcon(const gfx::ImageSkia& icon);
// Adds a checkbox with the specified label to the message box if this is the
// first call. Otherwise, it changes the label of the current checkbox. To
// start, the message box has no checkbox until this function is called.
......@@ -107,9 +98,6 @@ class VIEWS_EXPORT MessageBoxView : public View {
// Input text field for the message box.
Textfield* prompt_field_;
// Icon displayed in the upper left corner of the message box.
ImageView* icon_;
// Checkbox for the message box.
Checkbox* checkbox_;
......
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