Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 1141253002: [Views] Allow dialog delegates to use a custom padding for the extra view (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 17f71860057e63e8f736c39af8747044df309b31..8903650d45038bde4601fb5460873bc486ae79c5 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -177,13 +177,16 @@ void DialogClientView::OnDidChangeFocus(View* focused_before,
gfx::Size DialogClientView::GetPreferredSize() const {
// Initialize the size to fit the buttons and extra view row.
+ int extra_view_padding = 0;
+ if (!GetDialogDelegate()->GetExtraViewPadding(&extra_view_padding))
+ extra_view_padding = kRelatedButtonHSpacing;
gfx::Size size(
(ok_button_ ? ok_button_->GetPreferredSize().width() : 0) +
(cancel_button_ ? cancel_button_->GetPreferredSize().width() : 0) +
(cancel_button_ && ok_button_ ? kRelatedButtonHSpacing : 0) +
(ShouldShow(extra_view_) ? extra_view_->GetPreferredSize().width() : 0) +
(ShouldShow(extra_view_) && has_dialog_buttons() ?
- kRelatedButtonHSpacing : 0),
+ extra_view_padding : 0),
0);
int buttons_height = GetButtonsAndExtraViewRowHeight();
@@ -239,6 +242,14 @@ void DialogClientView::Layout() {
LayoutButton(cancel_button_, &row_bounds);
}
if (extra_view_) {
+ int custom_padding = 0;
+ if (has_dialog_buttons() &&
+ GetDialogDelegate()->GetExtraViewPadding(&custom_padding)) {
+ // The call to LayoutButton() will already have accounted for some of
+ // the padding.
+ custom_padding -= kRelatedButtonHSpacing;
+ row_bounds.set_width(row_bounds.width() - custom_padding);
+ }
row_bounds.set_width(std::min(row_bounds.width(),
extra_view_->GetPreferredSize().width()));
extra_view_->SetBoundsRect(row_bounds);
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698