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

Unified Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 2696263002: Refactor ViewsDelegate and MD-ify the icon-to-text spacing for checkbox and radiobutton (Closed)
Patch Set: Added GetDefaultSpacingMetric to ViewsDelegate to start process of hiding layout constants 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: chrome/browser/ui/views/chrome_views_delegate.cc
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 889ec1b29ef2d6ada70644c9c5f33a4c19515dab..681b8e1cabf0e36b98d8615ff6557e0e21665238 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -549,53 +549,56 @@ ChromeViewsDelegate::GetBlockingPoolTaskRunner() {
return content::BrowserThread::GetBlockingPool();
}
-gfx::Insets ChromeViewsDelegate::GetDialogButtonInsets() const {
+gfx::Insets ChromeViewsDelegate::GetInsetsMetric(
+ views::InsetsMetric metric) const {
const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
- const int top = layout_delegate->GetMetric(
- LayoutDelegate::Metric::DIALOG_BUTTON_TOP_SPACING);
- const int margin = layout_delegate->GetMetric(
- LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
- return gfx::Insets(top, margin, margin, margin);
-}
-
-int ChromeViewsDelegate::GetDialogCloseButtonMargin() const {
- return LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::DIALOG_CLOSE_BUTTON_MARGIN);
-}
-
-int ChromeViewsDelegate::GetDialogRelatedButtonHorizontalSpacing() const {
- return LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING);
-}
-
-int ChromeViewsDelegate::GetDialogRelatedControlVerticalSpacing() const {
- return LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING);
-}
-
-gfx::Insets ChromeViewsDelegate::GetDialogFrameViewInsets() const {
- const LayoutDelegate* layout_delegate = LayoutDelegate::Get();
- const int top = layout_delegate->GetMetric(
- LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
- const int side = layout_delegate->GetMetric(
- LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
- // Titles are inset at the top and sides, but not at the bottom.
- return gfx::Insets(top, side, 0, side);
-}
-
-gfx::Insets ChromeViewsDelegate::GetBubbleDialogMargins() const {
- return gfx::Insets(LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::PANEL_CONTENT_MARGIN));
-}
-
-int ChromeViewsDelegate::GetDialogButtonMinimumWidth() const {
- return LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH);
-}
-
-int ChromeViewsDelegate::GetButtonHorizontalPadding() const {
- return LayoutDelegate::Get()->GetMetric(
- LayoutDelegate::Metric::BUTTON_HORIZONTAL_PADDING);
+ switch (metric) {
+ case views::InsetsMetric::DIALOG_BUTTON: {
+ const int top = layout_delegate->GetMetric(
+ LayoutDelegate::Metric::DIALOG_BUTTON_TOP_SPACING);
+ const int margin = layout_delegate->GetMetric(
+ LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
+ return gfx::Insets(top, margin, margin, margin);
+ }
+ case views::InsetsMetric::DIALOG_FRAME_VIEW: {
+ const int top = layout_delegate->GetMetric(
+ LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
+ const int side = layout_delegate->GetMetric(
+ LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN);
+ // Titles are inset at the top and sides, but not at the bottom.
+ return gfx::Insets(top, side, 0, side);
+ }
+ case views::InsetsMetric::BUBBLE_DIALOG:
+ return gfx::Insets(layout_delegate->GetMetric(
+ LayoutDelegate::Metric::PANEL_CONTENT_MARGIN));
+ }
+ NOTREACHED();
+ return gfx::Insets();
+}
+
+int ChromeViewsDelegate::GetSpacingMetric(views::SpacingMetric metric) const {
+ switch (metric) {
+ case views::SpacingMetric::CLOSE_BUTTON_MARGIN:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::DIALOG_CLOSE_BUTTON_MARGIN);
+ case views::SpacingMetric::RELATED_HORIZONTAL_BUTTON:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING);
+ case views::SpacingMetric::RELATED_VERTICAL_CONTROL:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING);
+ case views::SpacingMetric::ICON_TO_TEXT:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::ICON_TEXT_SPACING);
+ case views::SpacingMetric::DIALOG_BUTTON_MINIMUM_WIDTH:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::DIALOG_BUTTON_MINIMUM_WIDTH);
+ case views::SpacingMetric::BUTTON_HORIZONTAL_PADDING:
+ return LayoutDelegate::Get()->GetMetric(
+ LayoutDelegate::Metric::BUTTON_HORIZONTAL_PADDING);
+ }
+ NOTREACHED();
+ return 0;
}
#if !defined(USE_ASH)

Powered by Google App Engine
This is Rietveld 408576698