Commit 76f08ac8 authored by estade@chromium.org's avatar estade@chromium.org

fix GridLayout::CreatePanel for new style dialogs

BUG=231523

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194688 0039d316-1c4b-4281-b951-d872f2087c98
parent 6edd0533
...@@ -57,9 +57,15 @@ IdleActionWarningDialogView::IdleActionWarningDialogView() : closing_(false) { ...@@ -57,9 +57,15 @@ IdleActionWarningDialogView::IdleActionWarningDialogView() : closing_(false) {
FixedWidthLabel* content = new FixedWidthLabel( FixedWidthLabel* content = new FixedWidthLabel(
l10n_util::GetStringUTF16(IDS_IDLE_WARNING_LOGOUT_WARNING), l10n_util::GetStringUTF16(IDS_IDLE_WARNING_LOGOUT_WARNING),
kIdleActionWarningContentWidth); kIdleActionWarningContentWidth);
if (DialogDelegate::UseNewStyle()) {
content->set_border(views::Border::CreateEmptyBorder(
views::kPanelVertMargin, views::kButtonHEdgeMarginNew,
views::kPanelVertMargin, views::kButtonHEdgeMarginNew));
} else {
content->set_border(views::Border::CreateEmptyBorder( content->set_border(views::Border::CreateEmptyBorder(
views::kPanelVertMargin, views::kPanelHorizMargin, views::kPanelVertMargin, views::kPanelHorizMargin,
views::kPanelVertMargin, views::kPanelHorizMargin)); views::kPanelVertMargin, views::kPanelHorizMargin));
}
AddChildView(content); AddChildView(content);
SetLayoutManager(new views::FillLayout()); SetLayoutManager(new views::FillLayout());
......
...@@ -289,8 +289,6 @@ void BookmarkEditorView::Init() { ...@@ -289,8 +289,6 @@ void BookmarkEditorView::Init() {
} }
GridLayout* layout = GridLayout::CreatePanel(this); GridLayout* layout = GridLayout::CreatePanel(this);
if (views::DialogDelegate::UseNewStyle())
layout->SetInsets(gfx::Insets());
SetLayoutManager(layout); SetLayoutManager(layout);
const int labels_column_set_id = 0; const int labels_column_set_id = 0;
......
...@@ -15,13 +15,7 @@ ...@@ -15,13 +15,7 @@
ConfirmBubbleViews::ConfirmBubbleViews(ConfirmBubbleModel* model) ConfirmBubbleViews::ConfirmBubbleViews(ConfirmBubbleModel* model)
: model_(model), : model_(model),
link_(NULL) { link_(NULL) {
views::GridLayout* layout = new views::GridLayout(this); views::GridLayout* layout = views::GridLayout::CreatePanel(this);
// TODO(msw): Use layout constants and fix the new-style sizing.
layout->SetInsets(UseNewStyle() ? gfx::Insets(0, 0, 40, 0) :
gfx::Insets(views::kUnrelatedControlVerticalSpacing,
views::kUnrelatedControlHorizontalSpacing,
views::kUnrelatedControlVerticalSpacing,
views::kUnrelatedControlHorizontalSpacing));
SetLayoutManager(layout); SetLayoutManager(layout);
// Use a fixed maximum message width, so longer messages will wrap. // Use a fixed maximum message width, so longer messages will wrap.
......
...@@ -33,6 +33,12 @@ const int kIconSize = 69; ...@@ -33,6 +33,12 @@ const int kIconSize = 69;
class ExtensionUninstallDialogDelegateView; class ExtensionUninstallDialogDelegateView;
// TODO(estade): remove this when UseNewStyle() is the default.
int HorizontalMargin() {
return views::DialogDelegate::UseNewStyle() ? views::kButtonHEdgeMarginNew :
views::kPanelHorizMargin;
}
// Returns parent window for extension uninstall dialog. // Returns parent window for extension uninstall dialog.
// For ash, use app list window if it is visible. // For ash, use app list window if it is visible.
// For other platforms or when app list is not visible on ash, // For other platforms or when app list is not visible on ash,
...@@ -202,11 +208,11 @@ string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const { ...@@ -202,11 +208,11 @@ string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE); return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE);
} }
gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() { gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() {
int width = kRightColumnWidth; int width = kRightColumnWidth;
width += kIconSize; width += kIconSize;
width += views::kPanelHorizMargin * 3; width += HorizontalMargin() * 2;
width += views::kRelatedControlHorizontalSpacing;
int height = views::kPanelVertMargin * 2; int height = views::kPanelVertMargin * 2;
height += heading_->GetHeightForWidth(kRightColumnWidth); height += heading_->GetHeightForWidth(kRightColumnWidth);
...@@ -216,7 +222,7 @@ gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() { ...@@ -216,7 +222,7 @@ gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() {
} }
void ExtensionUninstallDialogDelegateView::Layout() { void ExtensionUninstallDialogDelegateView::Layout() {
int x = views::kPanelHorizMargin; int x = HorizontalMargin();
int y = views::kPanelVertMargin; int y = views::kPanelVertMargin;
heading_->SizeToFit(kRightColumnWidth); heading_->SizeToFit(kRightColumnWidth);
...@@ -224,7 +230,7 @@ void ExtensionUninstallDialogDelegateView::Layout() { ...@@ -224,7 +230,7 @@ void ExtensionUninstallDialogDelegateView::Layout() {
if (heading_->height() <= kIconSize) { if (heading_->height() <= kIconSize) {
icon_->SetBounds(x, y, kIconSize, kIconSize); icon_->SetBounds(x, y, kIconSize, kIconSize);
x += kIconSize; x += kIconSize;
x += views::kPanelHorizMargin; x += views::kRelatedControlHorizontalSpacing;
heading_->SetX(x); heading_->SetX(x);
heading_->SetY(y + (kIconSize - heading_->height()) / 2); heading_->SetY(y + (kIconSize - heading_->height()) / 2);
...@@ -234,7 +240,7 @@ void ExtensionUninstallDialogDelegateView::Layout() { ...@@ -234,7 +240,7 @@ void ExtensionUninstallDialogDelegateView::Layout() {
kIconSize, kIconSize,
kIconSize); kIconSize);
x += kIconSize; x += kIconSize;
x += views::kPanelHorizMargin; x += views::kRelatedControlHorizontalSpacing;
heading_->SetX(x); heading_->SetX(x);
heading_->SetY(y); heading_->SetY(y);
......
...@@ -101,9 +101,8 @@ void MediaGalleriesDialogViews::InitChildViews() { ...@@ -101,9 +101,8 @@ void MediaGalleriesDialogViews::InitChildViews() {
contents_->RemoveAllChildViews(true); contents_->RemoveAllChildViews(true);
int dialog_content_width = views::Widget::GetLocalizedContentsWidth( int dialog_content_width = views::Widget::GetLocalizedContentsWidth(
IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS); IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS);
views::GridLayout* layout = new views::GridLayout(contents_); views::GridLayout* layout = views::GridLayout::CreatePanel(contents_);
layout->SetInsets(views::kPanelVertMargin, views::kPanelHorizMargin, contents_->SetLayoutManager(layout);
0, views::kPanelHorizMargin);
int column_set_id = 0; int column_set_id = 0;
views::ColumnSet* columns = layout->AddColumnSet(column_set_id); views::ColumnSet* columns = layout->AddColumnSet(column_set_id);
...@@ -113,13 +112,8 @@ void MediaGalleriesDialogViews::InitChildViews() { ...@@ -113,13 +112,8 @@ void MediaGalleriesDialogViews::InitChildViews() {
views::GridLayout::FIXED, views::GridLayout::FIXED,
dialog_content_width, dialog_content_width,
0); 0);
contents_->SetLayoutManager(layout);
contents_->set_border(views::Border::CreateEmptyBorder(
views::kPanelSubVerticalSpacing,
0,
views::kPanelSubVerticalSpacing,
0));
if (!DialogDelegate::UseNewStyle()) {
// Header text. // Header text.
views::Label* header = new views::Label(controller_->GetHeader()); views::Label* header = new views::Label(controller_->GetHeader());
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
...@@ -127,6 +121,7 @@ void MediaGalleriesDialogViews::InitChildViews() { ...@@ -127,6 +121,7 @@ void MediaGalleriesDialogViews::InitChildViews() {
header->SetHorizontalAlignment(gfx::ALIGN_LEFT); header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
layout->AddView(header); layout->AddView(header);
}
// Message text. // Message text.
views::Label* subtext = new views::Label(controller_->GetSubtext()); views::Label* subtext = new views::Label(controller_->GetSubtext());
...@@ -311,7 +306,7 @@ string16 MediaGalleriesDialogViews::GetWindowTitle() const { ...@@ -311,7 +306,7 @@ string16 MediaGalleriesDialogViews::GetWindowTitle() const {
} }
bool MediaGalleriesDialogViews::ShouldShowWindowTitle() const { bool MediaGalleriesDialogViews::ShouldShowWindowTitle() const {
return false; return DialogDelegate::UseNewStyle();
} }
void MediaGalleriesDialogViews::DeleteDelegate() { void MediaGalleriesDialogViews::DeleteDelegate() {
......
...@@ -60,11 +60,19 @@ gfx::Size ImportLockDialogView::GetPreferredSize() { ...@@ -60,11 +60,19 @@ gfx::Size ImportLockDialogView::GetPreferredSize() {
} }
void ImportLockDialogView::Layout() { void ImportLockDialogView::Layout() {
if (DialogDelegate::UseNewStyle()) {
description_label_->SetBounds(
views::kButtonHEdgeMargin,
views::kPanelVertMargin,
width() - 2 * views::kButtonHEdgeMargin,
height() - 2 * views::kPanelVertMargin);
} else {
description_label_->SetBounds( description_label_->SetBounds(
views::kPanelHorizMargin, views::kPanelHorizMargin,
views::kPanelVertMargin, views::kPanelVertMargin,
width() - 2 * views::kPanelHorizMargin, width() - 2 * views::kPanelHorizMargin,
height() - 2 * views::kPanelVertMargin); height() - 2 * views::kPanelVertMargin);
}
} }
string16 ImportLockDialogView::GetDialogButtonLabel( string16 ImportLockDialogView::GetDialogButtonLabel(
......
...@@ -137,7 +137,7 @@ void SadTabView::ViewHierarchyChanged(bool is_add, ...@@ -137,7 +137,7 @@ void SadTabView::ViewHierarchyChanged(bool is_add,
if (child != this || !is_add) if (child != this || !is_add)
return; return;
views::GridLayout* layout = views::GridLayout::CreatePanel(this); views::GridLayout* layout = new views::GridLayout(this);
SetLayoutManager(layout); SetLayoutManager(layout);
const int column_set_id = 0; const int column_set_id = 0;
......
...@@ -497,9 +497,12 @@ void TaskManagerView::Layout() { ...@@ -497,9 +497,12 @@ void TaskManagerView::Layout() {
bool new_style = views::DialogDelegate::UseNewStyle(); bool new_style = views::DialogDelegate::UseNewStyle();
gfx::Size size = kill_button_->GetPreferredSize(); gfx::Size size = kill_button_->GetPreferredSize();
gfx::Rect parent_bounds = parent()->GetContentsBounds(); gfx::Rect parent_bounds = parent()->GetContentsBounds();
int x = width() - size.width() - (new_style ? 0 : views::kPanelHorizMargin); const int horizontal_margin =
int y_buttons = new_style ? GetLocalBounds().bottom() - size.height() : new_style ? views::kButtonHEdgeMarginNew : views::kPanelHorizMargin;
parent_bounds.bottom() - size.height() - views::kButtonVEdgeMargin; const int vertical_margin =
new_style ? views::kButtonVEdgeMarginNew : views::kButtonVEdgeMargin;
int x = width() - size.width() - horizontal_margin;
int y_buttons = parent_bounds.bottom() - size.height() - vertical_margin;
kill_button_->SetBounds(x, y_buttons, size.width(), size.height()); kill_button_->SetBounds(x, y_buttons, size.width(), size.height());
if (purge_memory_button_) { if (purge_memory_button_) {
...@@ -511,13 +514,13 @@ void TaskManagerView::Layout() { ...@@ -511,13 +514,13 @@ void TaskManagerView::Layout() {
} }
size = about_memory_link_->GetPreferredSize(); size = about_memory_link_->GetPreferredSize();
about_memory_link_->SetBounds(new_style ? 0 : views::kPanelHorizMargin, about_memory_link_->SetBounds(
horizontal_margin,
y_buttons + (kill_button_->height() - size.height()) / 2, y_buttons + (kill_button_->height() - size.height()) / 2,
size.width(), size.height()); size.width(), size.height());
gfx::Rect rect = GetLocalBounds(); gfx::Rect rect = GetLocalBounds();
if (!new_style) rect.Inset(horizontal_margin, views::kPanelVertMargin);
rect.Inset(views::kPanelHorizMargin, views::kPanelVertMargin);
rect.Inset(0, 0, 0, rect.Inset(0, 0, 0,
kill_button_->height() + views::kUnrelatedControlVerticalSpacing); kill_button_->height() + views::kUnrelatedControlVerticalSpacing);
tab_table_parent_->SetBoundsRect(rect); tab_table_parent_->SetBoundsRect(rect);
......
...@@ -66,14 +66,8 @@ MessageBoxView::InitParams::InitParams(const string16& message) ...@@ -66,14 +66,8 @@ MessageBoxView::InitParams::InitParams(const string16& message)
: options(NO_OPTIONS), : options(NO_OPTIONS),
message(message), message(message),
message_width(kDefaultMessageWidth), message_width(kDefaultMessageWidth),
top_inset(kPanelVertMargin),
bottom_inset(kPanelVertMargin),
left_inset(kPanelHorizMargin),
right_inset(kPanelHorizMargin),
inter_row_vertical_spacing(kRelatedControlVerticalSpacing), inter_row_vertical_spacing(kRelatedControlVerticalSpacing),
clipboard_source_tag() clipboard_source_tag() {}
{
}
MessageBoxView::InitParams::~InitParams() { MessageBoxView::InitParams::~InitParams() {
} }
...@@ -195,10 +189,6 @@ void MessageBoxView::Init(const InitParams& params) { ...@@ -195,10 +189,6 @@ void MessageBoxView::Init(const InitParams& params) {
prompt_field_->SetText(params.default_prompt); prompt_field_->SetText(params.default_prompt);
} }
top_inset_ = params.top_inset;
bottom_inset_ = params.bottom_inset;
left_inset_ = params.left_inset;
right_inset_ = params.right_inset;
inter_row_vertical_spacing_ = params.inter_row_vertical_spacing; inter_row_vertical_spacing_ = params.inter_row_vertical_spacing;
source_tag_ = params.clipboard_source_tag; source_tag_ = params.clipboard_source_tag;
...@@ -208,7 +198,6 @@ void MessageBoxView::Init(const InitParams& params) { ...@@ -208,7 +198,6 @@ void MessageBoxView::Init(const InitParams& params) {
void MessageBoxView::ResetLayoutManager() { void MessageBoxView::ResetLayoutManager() {
// Initialize the Grid Layout Manager used for this dialog box. // Initialize the Grid Layout Manager used for this dialog box.
GridLayout* layout = GridLayout::CreatePanel(this); GridLayout* layout = GridLayout::CreatePanel(this);
layout->SetInsets(top_inset_, bottom_inset_, left_inset_, right_inset_);
SetLayoutManager(layout); SetLayoutManager(layout);
gfx::Size icon_size; gfx::Size icon_size;
......
...@@ -48,10 +48,6 @@ class VIEWS_EXPORT MessageBoxView : public View { ...@@ -48,10 +48,6 @@ class VIEWS_EXPORT MessageBoxView : public View {
string16 message; string16 message;
string16 default_prompt; string16 default_prompt;
int message_width; int message_width;
int top_inset;
int bottom_inset;
int left_inset;
int right_inset;
int inter_row_vertical_spacing; int inter_row_vertical_spacing;
ui::Clipboard::SourceTag clipboard_source_tag; ui::Clipboard::SourceTag clipboard_source_tag;
}; };
...@@ -117,12 +113,6 @@ class VIEWS_EXPORT MessageBoxView : public View { ...@@ -117,12 +113,6 @@ class VIEWS_EXPORT MessageBoxView : public View {
// Maximum width of the message label. // Maximum width of the message label.
int message_width_; int message_width_;
// Insets for the grid layout.
int top_inset_;
int bottom_inset_;
int left_inset_;
int right_inset_;
// Spacing between rows in the grid layout. // Spacing between rows in the grid layout.
int inter_row_vertical_spacing_; int inter_row_vertical_spacing_;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ui/gfx/insets.h" #include "ui/gfx/insets.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/window/dialog_delegate.h"
namespace views { namespace views {
...@@ -675,8 +676,12 @@ GridLayout::~GridLayout() { ...@@ -675,8 +676,12 @@ GridLayout::~GridLayout() {
// static // static
GridLayout* GridLayout::CreatePanel(View* host) { GridLayout* GridLayout::CreatePanel(View* host) {
GridLayout* layout = new GridLayout(host); GridLayout* layout = new GridLayout(host);
layout->SetInsets(kPanelVertMargin, kPanelHorizMargin,
kPanelVertMargin, kPanelHorizMargin); const int horizontal_margin = DialogDelegate::UseNewStyle() ?
kButtonHEdgeMarginNew : kPanelHorizMargin;
layout->SetInsets(kPanelVertMargin, horizontal_margin,
kPanelVertMargin, horizontal_margin);
return layout; return layout;
} }
......
...@@ -62,6 +62,14 @@ const int kButtonVEdgeMargin = 9; ...@@ -62,6 +62,14 @@ const int kButtonVEdgeMargin = 9;
// left or right of a button. // left or right of a button.
const int kButtonHEdgeMargin = 13; const int kButtonHEdgeMargin = 13;
// Vertical spacing between the edge of the window and the
// top or bottom of a button (when using new style dialogs).
const int kButtonVEdgeMarginNew = 20;
// Vertical spacing between the edge of the window and the
// left or right of a button (when using new style dialogs).
const int kButtonHEdgeMarginNew = 20;
// Horizontal spacing between buttons that are logically related. // Horizontal spacing between buttons that are logically related.
const int kRelatedButtonHSpacing = 6; const int kRelatedButtonHSpacing = 6;
......
...@@ -372,7 +372,8 @@ gfx::Insets DialogClientView::GetButtonRowInsets() const { ...@@ -372,7 +372,8 @@ gfx::Insets DialogClientView::GetButtonRowInsets() const {
// NOTE: The insets only apply to the buttons, extra view, and footnote view. // NOTE: The insets only apply to the buttons, extra view, and footnote view.
return DialogDelegate::UseNewStyle() ? return DialogDelegate::UseNewStyle() ?
gfx::Insets(0, 20, 20, 20) : gfx::Insets(0, kButtonHEdgeMarginNew,
kButtonVEdgeMarginNew, kButtonHEdgeMarginNew) :
gfx::Insets(0, kButtonHEdgeMargin, gfx::Insets(0, kButtonHEdgeMargin,
kButtonVEdgeMargin, kButtonHEdgeMargin); kButtonVEdgeMargin, kButtonHEdgeMargin);
} }
......
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