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

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

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Reduced ViewsDelegate layout/metric functions to only two functions Created 3 years, 10 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 456ee7a2e0abd4aac4f9936f70254274921a6719..2926cb99e1f88f903c27c0818b8604843fa3d7a6 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -55,10 +55,11 @@ void LayoutButton(LabelButton* button,
row_bounds->right(),
row_bounds->y() + (row_bounds->height() - button_height) / 2,
size.width(), button_height);
- int spacing = ViewsDelegate::GetInstance()
- ? ViewsDelegate::GetInstance()
- ->GetDialogRelatedButtonHorizontalSpacing()
- : kRelatedButtonHSpacing;
+ int spacing =
+ ViewsDelegate::GetInstance()
+ ? ViewsDelegate::GetInstance()->GetSpacingMetric(
+ ViewsDelegate::SpacingMetric::RELATED_HORIZONTAL_BUTTON)
+ : kRelatedButtonHSpacing;
row_bounds->set_width(row_bounds->width() - spacing);
}
@@ -71,15 +72,13 @@ DialogClientView::DialogClientView(Widget* owner, View* contents_view)
: ClientView(owner, contents_view) {
button_row_insets_ =
ViewsDelegate::GetInstance()
- ? ViewsDelegate::GetInstance()->GetDialogButtonInsets()
+ ? ViewsDelegate::GetInstance()->GetInsetsMetric(
+ ViewsDelegate::InsetsMetric::DIALOG_BUTTON)
: gfx::Insets(0, kButtonHEdgeMarginNew, kButtonVEdgeMarginNew,
kButtonHEdgeMarginNew);
// Doing this now ensures this accelerator will have lower priority than
// one set by the contents view.
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
-
- if (ViewsDelegate::GetInstance())
- button_row_insets_ = ViewsDelegate::GetInstance()->GetDialogButtonInsets();
}
DialogClientView::~DialogClientView() {
@@ -157,21 +156,25 @@ 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 = ViewsDelegate::GetInstance()
- ? ViewsDelegate::GetInstance()
- ->GetDialogRelatedButtonHorizontalSpacing()
- : kRelatedButtonHSpacing;
+ extra_view_padding =
+ ViewsDelegate::GetInstance()
+ ? ViewsDelegate::GetInstance()->GetSpacingMetric(
+ ViewsDelegate::SpacingMetric::RELATED_HORIZONTAL_BUTTON)
+ : kRelatedButtonHSpacing;
gfx::Size size(
(ok_button_ ? ok_button_->GetPreferredSize().width() : 0) +
(cancel_button_ ? cancel_button_->GetPreferredSize().width() : 0) +
(cancel_button_ && ok_button_
- ? (ViewsDelegate::GetInstance()
- ? ViewsDelegate::GetInstance()
- ->GetDialogRelatedButtonHorizontalSpacing()
- : kRelatedButtonHSpacing) : 0) +
- (ShouldShow(extra_view_) ? extra_view_->GetPreferredSize().width() : 0) +
- (ShouldShow(extra_view_) && has_dialog_buttons() ? extra_view_padding
- : 0),
+ ? (ViewsDelegate::GetInstance()
+ ? ViewsDelegate::GetInstance()->GetSpacingMetric(
+ ViewsDelegate::SpacingMetric::
+ RELATED_HORIZONTAL_BUTTON)
+ : kRelatedButtonHSpacing)
+ : 0) +
+ (ShouldShow(extra_view_) ? extra_view_->GetPreferredSize().width()
+ : 0) +
+ (ShouldShow(extra_view_) && has_dialog_buttons() ? extra_view_padding
+ : 0),
0);
int buttons_height = GetButtonsAndExtraViewRowHeight();
@@ -374,12 +377,13 @@ int DialogClientView::GetButtonsAndExtraViewRowTopPadding() const {
// Some subclasses of DialogClientView, in order to do their own layout, set
// button_row_insets_ to gfx::Insets(). To avoid breaking behavior of those
// dialogs, supplying 0 for the top inset of the row falls back to
- // ViewsDelegate::GetRelatedControlVerticalSpacing or
+ // ViewsDelegate::GetSpacingMetric(
+ // ViewsDelegate::SpacingMetric::RELATED_VERTICAL_CONTROL) or
// kRelatedControlVerticalSpacing.
if (!spacing)
spacing = ViewsDelegate::GetInstance()
- ? ViewsDelegate::GetInstance()
- ->GetDialogRelatedControlVerticalSpacing()
+ ? ViewsDelegate::GetInstance()->GetSpacingMetric(
+ ViewsDelegate::SpacingMetric::RELATED_VERTICAL_CONTROL)
: kRelatedControlVerticalSpacing;
return spacing;
}

Powered by Google App Engine
This is Rietveld 408576698