| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/layout_constants.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ui/base/resource/material_design/material_design_controller.h" | |
| 9 | |
| 10 int GetLayoutConstant(LayoutConstant constant) { | |
| 11 const int kFindBarVerticalOffset[] = {1, 6, 6}; | |
| 12 const int kIconLabelViewInternalPadding[] = {3, 2, 2}; | |
| 13 const int kIconLabelViewTrailingPadding[] = {2, 8, 8}; | |
| 14 const int kLocationBarBorderThickness[] = {2, 1, 1}; | |
| 15 const int kLocationBarBubbleHorizontalPadding[] = {1, 4, 4}; | |
| 16 const int kLocationBarBubbleVerticalPadding[] = {1, 4, 4}; | |
| 17 const int kLocationBarHeight[] = {27, 28, 32}; | |
| 18 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; | |
| 19 const int kLocationBarVerticalPadding[] = {2, 2, 2}; | |
| 20 const int kNewTabButtonWidth[] = {34, 34, 34}; | |
| 21 const int kOmniboxDropdownBorderInterior[] = {6, 0, 0}; | |
| 22 const int kOmniboxFontPixelSize[] = {16, 14, 14}; | |
| 23 const int kTabCloseButtonTrailingPaddingOverlap[] = {2, 2, 2}; | |
| 24 const int kTabFaviconTitleSpacing[] = {4, 4, 4}; | |
| 25 const int kTabMaximumTitleWidth[] = {175, 175, 175}; | |
| 26 const int kTabPinnedContentWidth[] = {25, 25, 25}; | |
| 27 #if defined(OS_MACOSX) | |
| 28 const int kTabTopExclusionHeight[] = {0, 0, 0}; | |
| 29 const int kTabstripNewTabButtonOverlap[] = {8, 8, 8}; | |
| 30 const int kTabstripTabOverlap[] = {19, 19, 19}; | |
| 31 #else | |
| 32 const int kTabTopExclusionHeight[] = {2, 2, 2}; | |
| 33 const int kTabstripNewTabButtonOverlap[] = {11, 11, 11}; | |
| 34 const int kTabstripTabOverlap[] = {26, 26, 26}; | |
| 35 #endif | |
| 36 const int kTabstripToolbarOverlap[] = {3, 3, 3}; | |
| 37 const int kToolbarContentShadowHeight[] = {0, 0, 0}; | |
| 38 const int kToolbarContentShadowHeightAsh[] = {2, 0, 0}; | |
| 39 const int kToolbarElementPadding[] = {0, 0, 8}; | |
| 40 const int kToolbarLocationBarRightPadding[] = {0, 4, 8}; | |
| 41 const int kToolbarStandardSpacing[] = {3, 4, 8}; | |
| 42 | |
| 43 const int mode = ui::MaterialDesignController::GetMode(); | |
| 44 switch (constant) { | |
| 45 case FIND_BAR_TOOLBAR_OVERLAP: | |
| 46 return kFindBarVerticalOffset[mode]; | |
| 47 case ICON_LABEL_VIEW_INTERNAL_PADDING: | |
| 48 return kIconLabelViewInternalPadding[mode]; | |
| 49 case ICON_LABEL_VIEW_TRAILING_PADDING: | |
| 50 return kIconLabelViewTrailingPadding[mode]; | |
| 51 case LOCATION_BAR_BORDER_THICKNESS: | |
| 52 return kLocationBarBorderThickness[mode]; | |
| 53 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: | |
| 54 return kLocationBarBubbleHorizontalPadding[mode]; | |
| 55 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | |
| 56 return kLocationBarBubbleVerticalPadding[mode]; | |
| 57 case LOCATION_BAR_HEIGHT: | |
| 58 return kLocationBarHeight[mode]; | |
| 59 case LOCATION_BAR_HORIZONTAL_PADDING: | |
| 60 return kLocationBarHorizontalPadding[mode]; | |
| 61 case LOCATION_BAR_VERTICAL_PADDING: | |
| 62 return kLocationBarVerticalPadding[mode]; | |
| 63 case NEW_TAB_BUTTON_WIDTH: | |
| 64 return kNewTabButtonWidth[mode]; | |
| 65 case OMNIBOX_DROPDOWN_BORDER_INTERIOR: | |
| 66 return kOmniboxDropdownBorderInterior[mode]; | |
| 67 case OMNIBOX_FONT_PIXEL_SIZE: | |
| 68 return kOmniboxFontPixelSize[mode]; | |
| 69 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: | |
| 70 return kTabstripNewTabButtonOverlap[mode]; | |
| 71 case TABSTRIP_TAB_OVERLAP: | |
| 72 return kTabstripTabOverlap[mode]; | |
| 73 case TABSTRIP_TOOLBAR_OVERLAP: | |
| 74 return kTabstripToolbarOverlap[mode]; | |
| 75 case TAB_CLOSE_BUTTON_TRAILING_PADDING_OVERLAP: | |
| 76 return kTabCloseButtonTrailingPaddingOverlap[mode]; | |
| 77 case TAB_FAVICON_TITLE_SPACING: | |
| 78 return kTabFaviconTitleSpacing[mode]; | |
| 79 case TAB_MAXIMUM_TITLE_WIDTH: | |
| 80 return kTabMaximumTitleWidth[mode]; | |
| 81 case TAB_PINNED_CONTENT_WIDTH: | |
| 82 return kTabPinnedContentWidth[mode]; | |
| 83 case TAB_TOP_EXCLUSION_HEIGHT: | |
| 84 return kTabTopExclusionHeight[mode]; | |
| 85 case TOOLBAR_CONTENT_SHADOW_HEIGHT: | |
| 86 return kToolbarContentShadowHeight[mode]; | |
| 87 case TOOLBAR_CONTENT_SHADOW_HEIGHT_ASH: | |
| 88 return kToolbarContentShadowHeightAsh[mode]; | |
| 89 case TOOLBAR_ELEMENT_PADDING: | |
| 90 return kToolbarElementPadding[mode]; | |
| 91 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING: | |
| 92 return kToolbarLocationBarRightPadding[mode]; | |
| 93 case TOOLBAR_STANDARD_SPACING: | |
| 94 return kToolbarStandardSpacing[mode]; | |
| 95 } | |
| 96 NOTREACHED(); | |
| 97 return 0; | |
| 98 } | |
| 99 | |
| 100 gfx::Insets GetLayoutInsets(LayoutInset inset) { | |
| 101 const int kAvatarLeftPadding[] = {2, 4, 4}; | |
| 102 const int kAvatarRightPadding[] = {-6, 4, 4}; | |
| 103 const int kAvatarBottomPadding[] = {2, 4, 4}; | |
| 104 const int kOmniboxDropdownIconPadding[] = {2, 4, 8}; | |
| 105 const int kOmniboxDropdownPadding[] = {3, 4, 4}; | |
| 106 const int kOmniboxDropdownTextPadding[] = {3, 3, 3}; | |
| 107 const int kTabBottomPadding[] = {2, 2, 2}; | |
| 108 const int kTabLeftPadding[] = {20, 20, 20}; | |
| 109 const int kTabRightPadding[] = {20, 20, 20}; | |
| 110 const int kTabTopPadding[] = {4, 4, 4}; | |
| 111 const int kToolbarBottomPadding[] = {5, 5, 5}; | |
| 112 const int kToolbarButtonPadding[] = {2, 6, 6}; | |
| 113 const int kToolbarLeftPadding[] = {3, 4, 8}; | |
| 114 const int kToolbarRightPadding[] = {2, 4, 8}; | |
| 115 const int kToolbarTopPadding[] = {5, 4, 4}; | |
| 116 | |
| 117 const int mode = ui::MaterialDesignController::GetMode(); | |
| 118 switch (inset) { | |
| 119 case AVATAR_ICON: { | |
| 120 return gfx::Insets(0, kAvatarLeftPadding[mode], | |
| 121 kAvatarBottomPadding[mode], kAvatarRightPadding[mode]); | |
| 122 } | |
| 123 case OMNIBOX_DROPDOWN: { | |
| 124 const int padding = kOmniboxDropdownPadding[mode]; | |
| 125 return gfx::Insets(padding, 0, padding, 0); | |
| 126 } | |
| 127 case OMNIBOX_DROPDOWN_ICON: { | |
| 128 const int padding = kOmniboxDropdownIconPadding[mode]; | |
| 129 return gfx::Insets(padding, 0, padding, 0); | |
| 130 } | |
| 131 case OMNIBOX_DROPDOWN_TEXT: { | |
| 132 const int padding = kOmniboxDropdownTextPadding[mode]; | |
| 133 return gfx::Insets(padding, 0, padding, 0); | |
| 134 } | |
| 135 case TAB: | |
| 136 return gfx::Insets(kTabTopPadding[mode], kTabLeftPadding[mode], | |
| 137 kTabBottomPadding[mode], kTabRightPadding[mode]); | |
| 138 case TOOLBAR: | |
| 139 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode], | |
| 140 kToolbarBottomPadding[mode], | |
| 141 kToolbarRightPadding[mode]); | |
| 142 case TOOLBAR_BUTTON: { | |
| 143 const int inset = kToolbarButtonPadding[mode]; | |
| 144 return gfx::Insets(inset, inset, inset, inset); | |
| 145 } | |
| 146 } | |
| 147 NOTREACHED(); | |
| 148 return gfx::Insets(); | |
| 149 } | |
| OLD | NEW |