OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/layout_constants.h" | 5 #include "chrome/browser/ui/layout_constants.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/resource/material_design/material_design_controller.h" | 8 #include "ui/base/resource/material_design/material_design_controller.h" |
9 | 9 |
10 int GetLayoutConstant(LayoutConstant constant) { | 10 int GetLayoutConstant(LayoutConstant constant) { |
11 const int kFindBarVerticalOffset[] = {1, 6, 6}; | 11 const int kFindBarVerticalOffset[] = {1, 6, 6}; |
12 const int kIconLabelViewInternalPadding[] = {3, 2, 2}; | 12 const int kIconLabelViewInternalPadding[] = {3, 2, 2}; |
13 const int kIconLabelViewTrailingPadding[] = {2, 8, 8}; | 13 const int kIconLabelViewTrailingPadding[] = {2, 8, 8}; |
14 const int kLocationBarBorderThickness[] = {2, 1, 1}; | 14 const int kLocationBarBorderThickness[] = {2, 1, 1}; |
15 const int kLocationBarBubbleHorizontalPadding[] = {1, 4, 4}; | 15 const int kLocationBarBubbleHorizontalPadding[] = {1, 4, 4}; |
16 const int kLocationBarBubbleVerticalPadding[] = {1, 4, 4}; | 16 const int kLocationBarBubbleVerticalPadding[] = {1, 4, 4}; |
17 const int kLocationBarHeight[] = {27, 28, 32}; | 17 const int kLocationBarHeight[] = {27, 28, 32}; |
18 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; | 18 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; |
19 const int kLocationBarVerticalPadding[] = {2, 2, 2}; | 19 const int kLocationBarVerticalPadding[] = {2, 2, 2}; |
20 const int kNewTabButtonWidth[] = {34, 36, 36}; | |
21 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; | 20 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; |
22 const int kOmniboxFontPixelSize[] = {16, 14, 14}; | 21 const int kOmniboxFontPixelSize[] = {16, 14, 14}; |
23 const int kTabCloseButtonTrailingPaddingOverlap[] = {2, 0, 0}; | 22 const int kTabCloseButtonTrailingPaddingOverlap[] = {2, 0, 0}; |
24 const int kTabFaviconTitleSpacing[] = {4, 6, 6}; | 23 const int kTabFaviconTitleSpacing[] = {4, 6, 6}; |
25 const int kTabMaximumTitleWidth[] = {175, 171, 171}; | 24 const int kTabHeight[] = {29, 29, 29}; |
26 const int kTabPinnedContentWidth[] = {25, 23, 23}; | 25 const int kTabPinnedContentWidth[] = {25, 23, 23}; |
27 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
28 const int kTabTopExclusionHeight[] = {0, 0, 0}; | 27 const int kTabTopExclusionHeight[] = {0, 0, 0}; |
29 const int kTabstripNewTabButtonOverlap[] = {8, 5, 5}; | 28 const int kTabstripNewTabButtonOverlap[] = {8, 5, 5}; |
30 const int kTabstripTabOverlap[] = {19, 16, 16}; | 29 const int kTabstripTabOverlap[] = {19, 16, 16}; |
31 #else | 30 #else |
32 const int kTabTopExclusionHeight[] = {2, 0, 0}; | 31 const int kTabTopExclusionHeight[] = {2, 0, 0}; |
33 const int kTabstripNewTabButtonOverlap[] = {11, 5, 5}; | 32 const int kTabstripNewTabButtonOverlap[] = {11, 5, 5}; |
34 const int kTabstripTabOverlap[] = {26, 16, 16}; | 33 const int kTabstripTabOverlap[] = {26, 16, 16}; |
35 #endif | 34 #endif |
(...skipping 17 matching lines...) Expand all Loading... |
53 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: | 52 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: |
54 return kLocationBarBubbleHorizontalPadding[mode]; | 53 return kLocationBarBubbleHorizontalPadding[mode]; |
55 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | 54 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: |
56 return kLocationBarBubbleVerticalPadding[mode]; | 55 return kLocationBarBubbleVerticalPadding[mode]; |
57 case LOCATION_BAR_HEIGHT: | 56 case LOCATION_BAR_HEIGHT: |
58 return kLocationBarHeight[mode]; | 57 return kLocationBarHeight[mode]; |
59 case LOCATION_BAR_HORIZONTAL_PADDING: | 58 case LOCATION_BAR_HORIZONTAL_PADDING: |
60 return kLocationBarHorizontalPadding[mode]; | 59 return kLocationBarHorizontalPadding[mode]; |
61 case LOCATION_BAR_VERTICAL_PADDING: | 60 case LOCATION_BAR_VERTICAL_PADDING: |
62 return kLocationBarVerticalPadding[mode]; | 61 return kLocationBarVerticalPadding[mode]; |
63 case NEW_TAB_BUTTON_WIDTH: | |
64 return kNewTabButtonWidth[mode]; | |
65 case OMNIBOX_DROPDOWN_BORDER_INTERIOR: | 62 case OMNIBOX_DROPDOWN_BORDER_INTERIOR: |
66 return kOmniboxDropdownBorderInterior[mode]; | 63 return kOmniboxDropdownBorderInterior[mode]; |
67 case OMNIBOX_FONT_PIXEL_SIZE: | 64 case OMNIBOX_FONT_PIXEL_SIZE: |
68 return kOmniboxFontPixelSize[mode]; | 65 return kOmniboxFontPixelSize[mode]; |
69 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: | 66 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: |
70 return kTabstripNewTabButtonOverlap[mode]; | 67 return kTabstripNewTabButtonOverlap[mode]; |
71 case TABSTRIP_TAB_OVERLAP: | 68 case TABSTRIP_TAB_OVERLAP: |
72 return kTabstripTabOverlap[mode]; | 69 return kTabstripTabOverlap[mode]; |
73 case TABSTRIP_TOOLBAR_OVERLAP: | 70 case TABSTRIP_TOOLBAR_OVERLAP: |
74 return kTabstripToolbarOverlap[mode]; | 71 return kTabstripToolbarOverlap[mode]; |
75 case TAB_CLOSE_BUTTON_TRAILING_PADDING_OVERLAP: | 72 case TAB_CLOSE_BUTTON_TRAILING_PADDING_OVERLAP: |
76 return kTabCloseButtonTrailingPaddingOverlap[mode]; | 73 return kTabCloseButtonTrailingPaddingOverlap[mode]; |
77 case TAB_FAVICON_TITLE_SPACING: | 74 case TAB_FAVICON_TITLE_SPACING: |
78 return kTabFaviconTitleSpacing[mode]; | 75 return kTabFaviconTitleSpacing[mode]; |
79 case TAB_MAXIMUM_TITLE_WIDTH: | 76 case TAB_HEIGHT: |
80 return kTabMaximumTitleWidth[mode]; | 77 return kTabHeight[mode]; |
81 case TAB_PINNED_CONTENT_WIDTH: | 78 case TAB_PINNED_CONTENT_WIDTH: |
82 return kTabPinnedContentWidth[mode]; | 79 return kTabPinnedContentWidth[mode]; |
83 case TAB_TOP_EXCLUSION_HEIGHT: | 80 case TAB_TOP_EXCLUSION_HEIGHT: |
84 return kTabTopExclusionHeight[mode]; | 81 return kTabTopExclusionHeight[mode]; |
85 case TOOLBAR_CONTENT_SHADOW_HEIGHT: | 82 case TOOLBAR_CONTENT_SHADOW_HEIGHT: |
86 return kToolbarContentShadowHeight[mode]; | 83 return kToolbarContentShadowHeight[mode]; |
87 case TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH: | 84 case TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH: |
88 return kToolbarContentShadowHeightAsh[mode]; | 85 return kToolbarContentShadowHeightAsh[mode]; |
89 case TOOLBAR_ELEMENT_PADDING: | 86 case TOOLBAR_ELEMENT_PADDING: |
90 return kToolbarElementPadding[mode]; | 87 return kToolbarElementPadding[mode]; |
(...skipping 18 matching lines...) Expand all Loading... |
109 const int kTabRightPadding[] = {20, 16, 16}; | 106 const int kTabRightPadding[] = {20, 16, 16}; |
110 const int kTabTopPadding[] = {4, 1, 1}; | 107 const int kTabTopPadding[] = {4, 1, 1}; |
111 const int kToolbarBottomPadding[] = {5, 5, 5}; | 108 const int kToolbarBottomPadding[] = {5, 5, 5}; |
112 const int kToolbarButtonPadding[] = {2, 6, 6}; | 109 const int kToolbarButtonPadding[] = {2, 6, 6}; |
113 const int kToolbarLeftPadding[] = {3, 4, 8}; | 110 const int kToolbarLeftPadding[] = {3, 4, 8}; |
114 const int kToolbarRightPadding[] = {2, 4, 8}; | 111 const int kToolbarRightPadding[] = {2, 4, 8}; |
115 const int kToolbarTopPadding[] = {5, 4, 4}; | 112 const int kToolbarTopPadding[] = {5, 4, 4}; |
116 | 113 |
117 const int mode = ui::MaterialDesignController::GetMode(); | 114 const int mode = ui::MaterialDesignController::GetMode(); |
118 switch (inset) { | 115 switch (inset) { |
119 case AVATAR_ICON: { | 116 case AVATAR_ICON: |
120 return gfx::Insets(0, kAvatarLeftPadding[mode], | 117 return gfx::Insets(0, kAvatarLeftPadding[mode], |
121 kAvatarBottomPadding[mode], kAvatarRightPadding[mode]); | 118 kAvatarBottomPadding[mode], kAvatarRightPadding[mode]); |
122 } | |
123 case OMNIBOX_DROPDOWN: { | 119 case OMNIBOX_DROPDOWN: { |
124 const int padding = kOmniboxDropdownPadding[mode]; | 120 const int padding = kOmniboxDropdownPadding[mode]; |
125 return gfx::Insets(padding, 0, padding, 0); | 121 return gfx::Insets(padding, 0, padding, 0); |
126 } | 122 } |
127 case OMNIBOX_DROPDOWN_ICON: { | 123 case OMNIBOX_DROPDOWN_ICON: { |
128 const int padding = kOmniboxDropdownIconPadding[mode]; | 124 const int padding = kOmniboxDropdownIconPadding[mode]; |
129 return gfx::Insets(padding, 0, padding, 0); | 125 return gfx::Insets(padding, 0, padding, 0); |
130 } | 126 } |
131 case OMNIBOX_DROPDOWN_TEXT: { | 127 case OMNIBOX_DROPDOWN_TEXT: { |
132 const int padding = kOmniboxDropdownTextPadding[mode]; | 128 const int padding = kOmniboxDropdownTextPadding[mode]; |
133 return gfx::Insets(padding, 0, padding, 0); | 129 return gfx::Insets(padding, 0, padding, 0); |
134 } | 130 } |
135 case TAB: | 131 case TAB: |
136 return gfx::Insets(kTabTopPadding[mode], kTabLeftPadding[mode], | 132 return gfx::Insets(kTabTopPadding[mode], kTabLeftPadding[mode], |
137 kTabBottomPadding[mode], kTabRightPadding[mode]); | 133 kTabBottomPadding[mode], kTabRightPadding[mode]); |
138 case TOOLBAR: | 134 case TOOLBAR: |
139 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode], | 135 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode], |
140 kToolbarBottomPadding[mode], | 136 kToolbarBottomPadding[mode], |
141 kToolbarRightPadding[mode]); | 137 kToolbarRightPadding[mode]); |
142 case TOOLBAR_BUTTON: { | 138 case TOOLBAR_BUTTON: { |
143 const int inset = kToolbarButtonPadding[mode]; | 139 const int inset = kToolbarButtonPadding[mode]; |
144 return gfx::Insets(inset, inset, inset, inset); | 140 return gfx::Insets(inset, inset, inset, inset); |
145 } | 141 } |
146 } | 142 } |
147 NOTREACHED(); | 143 NOTREACHED(); |
148 return gfx::Insets(); | 144 return gfx::Insets(); |
149 } | 145 } |
| 146 |
| 147 gfx::Size GetLayoutSize(LayoutSize size) { |
| 148 const int kNewTabButtonWidth[] = {34, 36, 36}; |
| 149 const int kNewTabButtonHeight[] = {18, 18, 18}; |
| 150 |
| 151 const int mode = ui::MaterialDesignController::GetMode(); |
| 152 switch (size) { |
| 153 case NEW_TAB_BUTTON: |
| 154 return gfx::Size(kNewTabButtonWidth[mode], kNewTabButtonHeight[mode]); |
| 155 } |
| 156 NOTREACHED(); |
| 157 return gfx::Size(); |
| 158 } |
OLD | NEW |