Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / layout_constants.cc
blob4acf9a5c81332d9ec233ee7c13f614e33962fa01
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/layout_constants.h"
7 #include "base/logging.h"
8 #include "ui/base/resource/material_design/material_design_controller.h"
10 int GetLayoutConstant(LayoutConstant constant) {
11 const int kIconLabelViewTrailingPadding[] = {2, 8, 8};
12 const int kLocationBarBubbleHorizontalPadding[] = {1, 5, 5};
13 const int kLocationBarBubbleVerticalPadding[] = {1, 3, 3};
14 const int kLocationBarHeight[] = {0, 28, 32};
15 const int kLocationBarHorizontalPadding[] = {3, 6, 6};
16 const int kLocationBarVerticalPadding[] = {2, 2, 2};
17 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0};
18 const int kOmniboxFontPixelSize[] = {16, 14, 14};
19 const int kTabCloseButtonTrailingPaddingOverlap[] = {3, 3, 3};
20 const int kTabFaviconTitleSpacing[] = {4, 4, 4};
21 const int kTabMaximumTitleWidth[] = {175, 175, 175};
22 const int kTabPinnedContentWidth[] = {25, 25, 25};
23 #if defined(OS_MACOSX)
24 const int kTabstripTabOverlap[] = {19, 19, 19};
25 #else
26 const int kTabstripTabOverlap[] = {26, 26, 26};
27 #endif
28 const int kTabstripToolbarOverlap[] = {3, 3, 3};
29 const int kTabstripTopShadowHeight[] = {3, 3, 3};
30 const int kToolbarContentShadowHeight[] = {0, 0, 0};
31 const int kToolbarContentShadowHeightAsh[] = {2, 0, 0};
32 const int kToolbarElementPadding[] = {0, 0, 8};
33 const int kToolbarLocationBarRightPadding[] = {0, 4, 8};
34 const int kToolbarStandardSpacing[] = {3, 4, 8};
36 const int mode = ui::MaterialDesignController::GetMode();
37 switch (constant) {
38 case ICON_LABEL_VIEW_TRAILING_PADDING:
39 return kIconLabelViewTrailingPadding[mode];
40 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING:
41 return kLocationBarBubbleHorizontalPadding[mode];
42 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING:
43 return kLocationBarBubbleVerticalPadding[mode];
44 case LOCATION_BAR_HEIGHT:
45 return kLocationBarHeight[mode];
46 case LOCATION_BAR_HORIZONTAL_PADDING:
47 return kLocationBarHorizontalPadding[mode];
48 case LOCATION_BAR_VERTICAL_PADDING:
49 return kLocationBarVerticalPadding[mode];
50 case OMNIBOX_DROPDOWN_BORDER_INTERIOR:
51 return kOmniboxDropdownBorderInterior[mode];
52 case OMNIBOX_FONT_PIXEL_SIZE:
53 return kOmniboxFontPixelSize[mode];
54 case TABSTRIP_TAB_OVERLAP:
55 return kTabstripTabOverlap[mode];
56 case TABSTRIP_TOOLBAR_OVERLAP:
57 return kTabstripToolbarOverlap[mode];
58 case TABSTRIP_TOP_SHADOW_HEIGHT:
59 return kTabstripTopShadowHeight[mode];
60 case TAB_CLOSE_BUTTON_TRAILING_PADDING_OVERLAP:
61 return kTabCloseButtonTrailingPaddingOverlap[mode];
62 case TAB_FAVICON_TITLE_SPACING:
63 return kTabFaviconTitleSpacing[mode];
64 case TAB_MAXIMUM_TITLE_WIDTH:
65 return kTabMaximumTitleWidth[mode];
66 case TAB_PINNED_CONTENT_WIDTH:
67 return kTabPinnedContentWidth[mode];
68 case TOOLBAR_CONTENT_SHADOW_HEIGHT:
69 return kToolbarContentShadowHeight[mode];
70 case TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH:
71 return kToolbarContentShadowHeightAsh[mode];
72 case TOOLBAR_ELEMENT_PADDING:
73 return kToolbarElementPadding[mode];
74 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING:
75 return kToolbarLocationBarRightPadding[mode];
76 case TOOLBAR_STANDARD_SPACING:
77 return kToolbarStandardSpacing[mode];
79 NOTREACHED();
80 return 0;
83 gfx::Insets GetLayoutInsets(LayoutInset inset) {
84 const int kOmniboxDropdownIconPadding[] = {2, 4, 8};
85 const int kOmniboxDropdownTextPadding[] = {3, 4, 8};
86 const int kTabBottomPadding[] = {2, 2, 2};
87 const int kTabLeftPadding[] = {20, 20, 20};
88 const int kTabRightPadding[] = {20, 20, 20};
89 const int kTabTopPadding[] = {4, 4, 4};
90 const int kToolbarBottomPadding[] = {5, 5, 5};
91 const int kToolbarButtonPadding[] = {2, 6, 6};
92 const int kToolbarLeftPadding[] = {3, 4, 8};
93 const int kToolbarRightPadding[] = {2, 4, 8};
94 const int kToolbarTopPadding[] = {5, 4, 4};
96 const int mode = ui::MaterialDesignController::GetMode();
97 switch (inset) {
98 case OMNIBOX_DROPDOWN_ICON: {
99 const int padding = kOmniboxDropdownIconPadding[mode];
100 return gfx::Insets(padding, 0, padding, 0);
102 case OMNIBOX_DROPDOWN_TEXT: {
103 const int padding = kOmniboxDropdownTextPadding[mode];
104 return gfx::Insets(padding, 0, padding, 0);
106 case TAB:
107 return gfx::Insets(kTabTopPadding[mode], kTabLeftPadding[mode],
108 kTabBottomPadding[mode], kTabRightPadding[mode]);
109 case TOOLBAR:
110 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode],
111 kToolbarBottomPadding[mode],
112 kToolbarRightPadding[mode]);
113 case TOOLBAR_BUTTON: {
114 const int inset = kToolbarButtonPadding[mode];
115 return gfx::Insets(inset, inset, inset, inset);
118 NOTREACHED();
119 return gfx::Insets();