Index: ui/views/window/dialog_client_view.cc |
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc |
index 4349a85b18a1b51a2e8b9e401eaa8921208e478d..94891c7620e1ecf92cac5dec0d27c106ff1bc7ff 100644 |
--- a/ui/views/window/dialog_client_view.cc |
+++ b/ui/views/window/dialog_client_view.cc |
@@ -54,10 +54,13 @@ void LayoutButton(LabelButton* button, gfx::Rect* row_bounds) { |
DialogClientView::DialogClientView(Widget* owner, View* contents_view) |
: ClientView(owner, contents_view), |
+ button_row_insets_(gfx::Insets(0, |
sky
2016/02/23 17:56:15
you shouldn't need the extra gfx::Insets here, tha
Evan Stade
2016/02/23 19:02:36
Done.
|
+ kButtonHEdgeMarginNew, |
+ kButtonVEdgeMarginNew, |
+ kButtonHEdgeMarginNew)), |
ok_button_(NULL), |
cancel_button_(NULL), |
extra_view_(NULL), |
- footnote_view_(NULL), |
delegate_allowed_close_(false) {} |
DialogClientView::~DialogClientView() { |
@@ -81,13 +84,10 @@ void DialogClientView::CancelWindow() { |
void DialogClientView::UpdateDialogButtons() { |
const int buttons = GetDialogDelegate()->GetDialogButtons(); |
- ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE); |
if (buttons & ui::DIALOG_BUTTON_OK) { |
if (!ok_button_) { |
ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK); |
- if (!(buttons & ui::DIALOG_BUTTON_CANCEL)) |
- ok_button_->AddAccelerator(escape); |
AddChildView(ok_button_); |
} |
@@ -100,7 +100,6 @@ void DialogClientView::UpdateDialogButtons() { |
if (buttons & ui::DIALOG_BUTTON_CANCEL) { |
if (!cancel_button_) { |
cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL); |
- cancel_button_->AddAccelerator(escape); |
AddChildView(cancel_button_); |
} |
@@ -109,12 +108,6 @@ void DialogClientView::UpdateDialogButtons() { |
delete cancel_button_; |
cancel_button_ = NULL; |
} |
- |
- // Use the escape key to close the window if there are no dialog buttons. |
- if (!has_dialog_buttons()) |
- AddAccelerator(escape); |
- else |
- ResetAccelerators(); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -167,31 +160,12 @@ gfx::Size DialogClientView::GetPreferredSize() const { |
size.Enlarge(0, contents_size.height()); |
size.set_width(std::max(size.width(), contents_size.width())); |
- // Increase the size as needed to fit the footnote view. |
- if (ShouldShow(footnote_view_)) { |
- gfx::Size footnote_size = footnote_view_->GetPreferredSize(); |
- if (!footnote_size.IsEmpty()) |
- size.set_width(std::max(size.width(), footnote_size.width())); |
- |
- int footnote_height = footnote_view_->GetHeightForWidth(size.width()); |
- size.Enlarge(0, footnote_height); |
- } |
- |
return size; |
} |
void DialogClientView::Layout() { |
gfx::Rect bounds = GetContentsBounds(); |
- // Layout the footnote view. |
- if (ShouldShow(footnote_view_)) { |
- const int height = footnote_view_->GetHeightForWidth(bounds.width()); |
- footnote_view_->SetBounds(bounds.x(), bounds.bottom() - height, |
- bounds.width(), height); |
- if (height != 0) |
- bounds.Inset(0, 0, 0, height); |
- } |
- |
// Layout the row containing the buttons and the extra view. |
if (has_dialog_buttons() || ShouldShow(extra_view_)) { |
bounds.Inset(GetButtonRowInsets()); |
@@ -242,7 +216,8 @@ void DialogClientView::ViewHierarchyChanged( |
if (details.is_add && details.child == this) { |
UpdateDialogButtons(); |
CreateExtraView(); |
- CreateFootnoteView(); |
+ // Use the escape key to close the window. |
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
} else if (!details.is_add && details.child != this) { |
if (details.child == ok_button_) |
ok_button_ = NULL; |
@@ -286,7 +261,6 @@ DialogClientView::DialogClientView(View* contents_view) |
ok_button_(NULL), |
cancel_button_(NULL), |
extra_view_(NULL), |
- footnote_view_(NULL), |
delegate_allowed_close_(false) {} |
DialogDelegate* DialogClientView::GetDialogDelegate() const { |
@@ -304,17 +278,8 @@ void DialogClientView::CreateExtraView() { |
} |
} |
-void DialogClientView::CreateFootnoteView() { |
- if (footnote_view_) |
- return; |
- |
- footnote_view_ = GetDialogDelegate()->CreateFootnoteView(); |
- if (footnote_view_) |
- AddChildView(footnote_view_); |
-} |
- |
void DialogClientView::ChildPreferredSizeChanged(View* child) { |
- if (child == footnote_view_ || child == extra_view_) |
+ if (child == extra_view_) |
Layout(); |
} |
@@ -362,10 +327,8 @@ int DialogClientView::GetButtonsAndExtraViewRowHeight() const { |
} |
gfx::Insets DialogClientView::GetButtonRowInsets() const { |
- // NOTE: The insets only apply to the buttons, extra view, and footnote view. |
- return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() : |
- gfx::Insets(0, kButtonHEdgeMarginNew, |
- kButtonVEdgeMarginNew, kButtonHEdgeMarginNew); |
+ return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() |
+ : button_row_insets_; |
} |
} // namespace views |