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/views/layout_constants.h" | 5 #include "chrome/browser/ui/views/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 kIconLabelViewTrailingPadding[] = {2, 8, 8}; | 11 const int kIconLabelViewTrailingPadding[] = {2, 8, 8}; |
12 const int kLocationBarBubbleHorizontalPadding[] = {1, 5, 5}; | 12 const int kLocationBarBubbleHorizontalPadding[] = {1, 5, 5}; |
13 const int kLocationBarBubbleVerticalPadding[] = {1, 3, 3}; | 13 const int kLocationBarBubbleVerticalPadding[] = {1, 3, 3}; |
14 const int kLocationBarHeight[] = {0, 28, 32}; | 14 const int kLocationBarHeight[] = {0, 28, 32}; |
15 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; | 15 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; |
16 const int kLocationBarVerticalPadding[] = {2, 2, 2}; | 16 const int kLocationBarVerticalPadding[] = {2, 2, 2}; |
17 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; | 17 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; |
18 const int kOmniboxFontPixelSize[] = {16, 14, 14}; | 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}; |
19 const int kToolbarViewContentShadowHeight[] = {0, 0, 0}; | 30 const int kToolbarViewContentShadowHeight[] = {0, 0, 0}; |
20 const int kToolbarViewContentShadowHeightAsh[] = {2, 0, 0}; | 31 const int kToolbarViewContentShadowHeightAsh[] = {2, 0, 0}; |
21 const int kToolbarViewElementPadding[] = {0, 0, 8}; | 32 const int kToolbarViewElementPadding[] = {0, 0, 8}; |
22 const int kToolbarViewLocationBarRightPadding[] = {0, 4, 8}; | 33 const int kToolbarViewLocationBarRightPadding[] = {0, 4, 8}; |
23 const int kToolbarViewStandardSpacing[] = {3, 4, 8}; | 34 const int kToolbarViewStandardSpacing[] = {3, 4, 8}; |
24 | 35 |
25 const int mode = ui::MaterialDesignController::GetMode(); | 36 const int mode = ui::MaterialDesignController::GetMode(); |
26 switch (constant) { | 37 switch (constant) { |
27 case ICON_LABEL_VIEW_TRAILING_PADDING: | 38 case ICON_LABEL_VIEW_TRAILING_PADDING: |
28 return kIconLabelViewTrailingPadding[mode]; | 39 return kIconLabelViewTrailingPadding[mode]; |
29 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: | 40 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: |
30 return kLocationBarBubbleHorizontalPadding[mode]; | 41 return kLocationBarBubbleHorizontalPadding[mode]; |
31 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | 42 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: |
32 return kLocationBarBubbleVerticalPadding[mode]; | 43 return kLocationBarBubbleVerticalPadding[mode]; |
33 case LOCATION_BAR_HEIGHT: | 44 case LOCATION_BAR_HEIGHT: |
34 return kLocationBarHeight[mode]; | 45 return kLocationBarHeight[mode]; |
35 case LOCATION_BAR_HORIZONTAL_PADDING: | 46 case LOCATION_BAR_HORIZONTAL_PADDING: |
36 return kLocationBarHorizontalPadding[mode]; | 47 return kLocationBarHorizontalPadding[mode]; |
37 case LOCATION_BAR_VERTICAL_PADDING: | 48 case LOCATION_BAR_VERTICAL_PADDING: |
38 return kLocationBarVerticalPadding[mode]; | 49 return kLocationBarVerticalPadding[mode]; |
39 case OMNIBOX_DROPDOWN_BORDER_INTERIOR: | 50 case OMNIBOX_DROPDOWN_BORDER_INTERIOR: |
40 return kOmniboxDropdownBorderInterior[mode]; | 51 return kOmniboxDropdownBorderInterior[mode]; |
41 case OMNIBOX_FONT_PIXEL_SIZE: | 52 case OMNIBOX_FONT_PIXEL_SIZE: |
42 return kOmniboxFontPixelSize[mode]; | 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]; |
43 case TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: | 68 case TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT: |
44 return kToolbarViewContentShadowHeight[mode]; | 69 return kToolbarViewContentShadowHeight[mode]; |
45 case TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: | 70 case TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH: |
46 return kToolbarViewContentShadowHeightAsh[mode]; | 71 return kToolbarViewContentShadowHeightAsh[mode]; |
47 case TOOLBAR_VIEW_ELEMENT_PADDING: | 72 case TOOLBAR_VIEW_ELEMENT_PADDING: |
48 return kToolbarViewElementPadding[mode]; | 73 return kToolbarViewElementPadding[mode]; |
49 case TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING: | 74 case TOOLBAR_VIEW_LOCATION_BAR_RIGHT_PADDING: |
50 return kToolbarViewLocationBarRightPadding[mode]; | 75 return kToolbarViewLocationBarRightPadding[mode]; |
51 case TOOLBAR_VIEW_STANDARD_SPACING: | 76 case TOOLBAR_VIEW_STANDARD_SPACING: |
52 return kToolbarViewStandardSpacing[mode]; | 77 return kToolbarViewStandardSpacing[mode]; |
53 } | 78 } |
54 NOTREACHED(); | 79 NOTREACHED(); |
55 return 0; | 80 return 0; |
56 } | 81 } |
57 | 82 |
58 gfx::Insets GetLayoutInsets(LayoutInset inset) { | 83 gfx::Insets GetLayoutInsets(LayoutInset inset) { |
59 const int kOmniboxDropdownMinIconVerticalPadding[] = {2, 4, 8}; | 84 const int kOmniboxDropdownMinIconVerticalPadding[] = {2, 4, 8}; |
60 const int kOmniboxDropdownMinTextVerticalPadding[] = {3, 4, 8}; | 85 const int kOmniboxDropdownMinTextVerticalPadding[] = {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}; |
61 const int kToolbarButtonBorderInset[] = {2, 6, 6}; | 90 const int kToolbarButtonBorderInset[] = {2, 6, 6}; |
62 const int kToolbarViewBottomVerticalPadding[] = {5, 5, 5}; | 91 const int kToolbarViewBottomVerticalPadding[] = {5, 5, 5}; |
63 const int kToolbarViewTopVerticalPadding[] = {5, 4, 4}; | 92 const int kToolbarViewTopVerticalPadding[] = {5, 4, 4}; |
64 const int kToolbarViewLeftEdgeSpacing[] = {3, 4, 8}; | 93 const int kToolbarViewLeftEdgeSpacing[] = {3, 4, 8}; |
65 const int kToolbarViewRightEdgeSpacing[] = {2, 4, 8}; | 94 const int kToolbarViewRightEdgeSpacing[] = {2, 4, 8}; |
66 | 95 |
67 const int mode = ui::MaterialDesignController::GetMode(); | 96 const int mode = ui::MaterialDesignController::GetMode(); |
68 switch (inset) { | 97 switch (inset) { |
69 case OMNIBOX_DROPDOWN_ICON: { | 98 case OMNIBOX_DROPDOWN_ICON: { |
70 const int padding = kOmniboxDropdownMinIconVerticalPadding[mode]; | 99 const int padding = kOmniboxDropdownMinIconVerticalPadding[mode]; |
71 return gfx::Insets(padding, 0, padding, 0); | 100 return gfx::Insets(padding, 0, padding, 0); |
72 } | 101 } |
73 case OMNIBOX_DROPDOWN_TEXT: { | 102 case OMNIBOX_DROPDOWN_TEXT: { |
74 const int padding = kOmniboxDropdownMinTextVerticalPadding[mode]; | 103 const int padding = kOmniboxDropdownMinTextVerticalPadding[mode]; |
75 return gfx::Insets(padding, 0, padding, 0); | 104 return gfx::Insets(padding, 0, padding, 0); |
76 } | 105 } |
| 106 case TAB: |
| 107 return gfx::Insets(kTabTopPadding[mode], kTabLeftPadding[mode], |
| 108 kTabBottomPadding[mode], kTabRightPadding[mode]); |
77 case TOOLBAR_BUTTON: { | 109 case TOOLBAR_BUTTON: { |
78 const int inset = kToolbarButtonBorderInset[mode]; | 110 const int inset = kToolbarButtonBorderInset[mode]; |
79 return gfx::Insets(inset, inset, inset, inset); | 111 return gfx::Insets(inset, inset, inset, inset); |
80 } | 112 } |
81 case TOOLBAR_VIEW: | 113 case TOOLBAR_VIEW: |
82 return gfx::Insets(kToolbarViewTopVerticalPadding[mode], | 114 return gfx::Insets(kToolbarViewTopVerticalPadding[mode], |
83 kToolbarViewLeftEdgeSpacing[mode], | 115 kToolbarViewLeftEdgeSpacing[mode], |
84 kToolbarViewBottomVerticalPadding[mode], | 116 kToolbarViewBottomVerticalPadding[mode], |
85 kToolbarViewRightEdgeSpacing[mode]); | 117 kToolbarViewRightEdgeSpacing[mode]); |
86 } | 118 } |
87 NOTREACHED(); | 119 NOTREACHED(); |
88 return gfx::Insets(); | 120 return gfx::Insets(); |
89 } | 121 } |
OLD | NEW |