summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/window/dialog_client_view.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 17fc332..d5574fa 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -300,6 +300,26 @@ gfx::Size DialogClientView::GetPreferredSize() {
button_height = ok_button_->height();
// Account for padding above and below the button.
button_height += kDialogButtonContentSpacing + kButtonVEdgeMargin;
+
+ // Make sure the view is sized to the buttons's width if they are wider than
+ // the contents.
+ int width = 0;
+ if (cancel_button_)
+ width += GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_CANCEL);
+ if (ok_button_) {
+ width += GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_OK);
+ if (cancel_button_)
+ width += kRelatedButtonHSpacing;
+ }
+ if (extra_view_) {
+ width += extra_view_->GetPreferredSize().width();
+ if (cancel_button_ || ok_button_)
+ width += kRelatedButtonHSpacing;
+ }
+ if (width > 0) {
+ width += 2 * kButtonHEdgeMargin;
+ prefsize.set_width(std::max(prefsize.width(), width));
+ }
}
prefsize.Enlarge(0, button_height);
return prefsize;