| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
| 10 | 10 |
| 11 int GetLayoutConstant(LayoutConstant constant) { | 11 int GetLayoutConstant(LayoutConstant constant) { |
| 12 const int kFindBarVerticalOffset[] = {1, 6, 6}; | 12 const int kFindBarVerticalOffset[] = {6, 6}; |
| 13 const int kLocationBarBorderThickness[] = {2, 1, 1}; | 13 const int kLocationBarBorderThickness[] = {1, 1}; |
| 14 const int kLocationBarBubbleFontVerticalPadding[] = {1, 2, 4}; | 14 const int kLocationBarBubbleFontVerticalPadding[] = {2, 4}; |
| 15 const int kLocationBarBubbleHorizontalPadding[] = {1, 0, 0}; | 15 const int kLocationBarBubbleVerticalPadding[] = {3, 3}; |
| 16 const int kLocationBarBubbleVerticalPadding[] = {1, 3, 3}; | 16 const int kLocationBarBubbleAnchorVerticalInset[] = {6, 8}; |
| 17 const int kLocationBarBubbleAnchorVerticalInset[] = {5, 6, 8}; | 17 const int kLocationBarHeight[] = {28, 32}; |
| 18 const int kLocationBarHeight[] = {27, 28, 32}; | 18 const int kLocationBarHorizontalPadding[] = {6, 6}; |
| 19 const int kLocationBarHorizontalPadding[] = {3, 6, 6}; | 19 const int kLocationBarVerticalPadding[] = {1, 1}; |
| 20 const int kLocationBarVerticalPadding[] = {0, 1, 1}; | 20 const int kOmniboxFontPixelSize[] = {14, 14}; |
| 21 const int kOmniboxFontPixelSize[] = {16, 14, 14}; | 21 const int kTabFaviconTitleSpacing[] = {6, 6}; |
| 22 const int kTabFaviconTitleSpacing[] = {4, 6, 6}; | 22 const int kTabHeight[] = {29, 33}; |
| 23 const int kTabHeight[] = {29, 29, 33}; | 23 const int kTabPinnedContentWidth[] = {23, 23}; |
| 24 const int kTabPinnedContentWidth[] = {25, 23, 23}; | 24 const int kTabstripNewTabButtonOverlap[] = {5, 6}; |
| 25 #if defined(OS_MACOSX) | 25 const int kTabstripTabOverlap[] = {16, 16}; |
| 26 const int kTabstripNewTabButtonOverlap[] = {8, 5, 6}; | 26 const int kToolbarStandardSpacing[] = {4, 8}; |
| 27 const int kTabstripTabOverlap[] = {19, 16, 16}; | 27 const int kToolbarElementPadding[] = {0, 8}; |
| 28 #else | 28 const int kToolbarLocationBarRightPadding[] = {4, 8}; |
| 29 const int kTabstripNewTabButtonOverlap[] = {11, 5, 6}; | |
| 30 const int kTabstripTabOverlap[] = {26, 16, 16}; | |
| 31 #endif | |
| 32 const int kToolbarStandardSpacing[] = {3, 4, 8}; | |
| 33 const int kToolbarElementPadding[] = {0, 0, 8}; | |
| 34 const int kToolbarLocationBarRightPadding[] = {0, 4, 8}; | |
| 35 | 29 |
| 36 const int mode = ui::MaterialDesignController::GetMode(); | 30 const int mode = ui::MaterialDesignController::GetMode(); |
| 37 switch (constant) { | 31 switch (constant) { |
| 38 case FIND_BAR_TOOLBAR_OVERLAP: | 32 case FIND_BAR_TOOLBAR_OVERLAP: |
| 39 return kFindBarVerticalOffset[mode]; | 33 return kFindBarVerticalOffset[mode]; |
| 40 case LOCATION_BAR_BORDER_THICKNESS: | 34 case LOCATION_BAR_BORDER_THICKNESS: |
| 41 return kLocationBarBorderThickness[mode]; | 35 return kLocationBarBorderThickness[mode]; |
| 42 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING: | 36 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING: |
| 43 return kLocationBarBubbleFontVerticalPadding[mode]; | 37 return kLocationBarBubbleFontVerticalPadding[mode]; |
| 44 case LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING: | |
| 45 return kLocationBarBubbleHorizontalPadding[mode]; | |
| 46 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | 38 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: |
| 47 return kLocationBarBubbleVerticalPadding[mode]; | 39 return kLocationBarBubbleVerticalPadding[mode]; |
| 48 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET: | 40 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET: |
| 49 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 41 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 50 return 1; | 42 return 1; |
| 51 return kLocationBarBubbleAnchorVerticalInset[mode]; | 43 return kLocationBarBubbleAnchorVerticalInset[mode]; |
| 52 case LOCATION_BAR_HEIGHT: | 44 case LOCATION_BAR_HEIGHT: |
| 53 return kLocationBarHeight[mode]; | 45 return kLocationBarHeight[mode]; |
| 54 case LOCATION_BAR_HORIZONTAL_PADDING: | 46 case LOCATION_BAR_HORIZONTAL_PADDING: |
| 55 return kLocationBarHorizontalPadding[mode]; | 47 return kLocationBarHorizontalPadding[mode]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING: | 64 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING: |
| 73 return kToolbarLocationBarRightPadding[mode]; | 65 return kToolbarLocationBarRightPadding[mode]; |
| 74 case TOOLBAR_STANDARD_SPACING: | 66 case TOOLBAR_STANDARD_SPACING: |
| 75 return kToolbarStandardSpacing[mode]; | 67 return kToolbarStandardSpacing[mode]; |
| 76 } | 68 } |
| 77 NOTREACHED(); | 69 NOTREACHED(); |
| 78 return 0; | 70 return 0; |
| 79 } | 71 } |
| 80 | 72 |
| 81 gfx::Insets GetLayoutInsets(LayoutInset inset) { | 73 gfx::Insets GetLayoutInsets(LayoutInset inset) { |
| 82 const int kAvatarLeftPadding[] = {2, 4, 4}; | 74 const int kAvatarLeftPadding[] = {4, 4}; |
| 83 const int kAvatarRightPadding[] = {-6, 4, 4}; | 75 const int kAvatarRightPadding[] = {4, 4}; |
| 84 const int kAvatarBottomPadding[] = {2, 4, 4}; | 76 const int kAvatarBottomPadding[] = {4, 4}; |
| 85 const int kOmniboxDropdownIconPadding[] = {2, 4, 8}; | 77 const int kOmniboxDropdownIconPadding[] = {4, 8}; |
| 86 const int kOmniboxDropdownPadding[] = {3, 4, 4}; | 78 const int kOmniboxDropdownPadding[] = {4, 4}; |
| 87 const int kOmniboxDropdownTextPadding[] = {3, 3, 3}; | 79 const int kOmniboxDropdownTextPadding[] = {3, 3}; |
| 88 const int kTabBottomPadding[] = {2, 1, 1}; | 80 const int kTabBottomPadding[] = {1, 1}; |
| 89 const int kTabHorizontalPadding[] = {20, 16, 18}; | 81 const int kTabHorizontalPadding[] = {16, 18}; |
| 90 const int kTabTopPadding[] = {4, 1, 1}; | 82 const int kTabTopPadding[] = {1, 1}; |
| 91 const int kToolbarBottomPadding[] = {5, 5, 5}; | 83 const int kToolbarBottomPadding[] = {5, 5}; |
| 92 const int kToolbarButtonPadding[] = {2, 6, 6}; | 84 const int kToolbarButtonPadding[] = {6, 6}; |
| 93 const int kToolbarLeftPadding[] = {3, 4, 8}; | 85 const int kToolbarLeftPadding[] = {4, 8}; |
| 94 const int kToolbarRightPadding[] = {2, 4, 8}; | 86 const int kToolbarRightPadding[] = {4, 8}; |
| 95 const int kToolbarTopPadding[] = {5, 4, 4}; | 87 const int kToolbarTopPadding[] = {4, 4}; |
| 96 | 88 |
| 97 const int mode = ui::MaterialDesignController::GetMode(); | 89 const int mode = ui::MaterialDesignController::GetMode(); |
| 98 switch (inset) { | 90 switch (inset) { |
| 99 case AVATAR_ICON: | 91 case AVATAR_ICON: |
| 100 return gfx::Insets(0, kAvatarLeftPadding[mode], | 92 return gfx::Insets(0, kAvatarLeftPadding[mode], |
| 101 kAvatarBottomPadding[mode], kAvatarRightPadding[mode]); | 93 kAvatarBottomPadding[mode], kAvatarRightPadding[mode]); |
| 102 case OMNIBOX_DROPDOWN: | 94 case OMNIBOX_DROPDOWN: |
| 103 return gfx::Insets(kOmniboxDropdownPadding[mode], 0); | 95 return gfx::Insets(kOmniboxDropdownPadding[mode], 0); |
| 104 case OMNIBOX_DROPDOWN_ICON: | 96 case OMNIBOX_DROPDOWN_ICON: |
| 105 return gfx::Insets(kOmniboxDropdownIconPadding[mode], 0); | 97 return gfx::Insets(kOmniboxDropdownIconPadding[mode], 0); |
| 106 case OMNIBOX_DROPDOWN_TEXT: | 98 case OMNIBOX_DROPDOWN_TEXT: |
| 107 return gfx::Insets(kOmniboxDropdownTextPadding[mode], 0); | 99 return gfx::Insets(kOmniboxDropdownTextPadding[mode], 0); |
| 108 case TAB: | 100 case TAB: |
| 109 return gfx::Insets(kTabTopPadding[mode], kTabHorizontalPadding[mode], | 101 return gfx::Insets(kTabTopPadding[mode], kTabHorizontalPadding[mode], |
| 110 kTabBottomPadding[mode], kTabHorizontalPadding[mode]); | 102 kTabBottomPadding[mode], kTabHorizontalPadding[mode]); |
| 111 case TOOLBAR: | 103 case TOOLBAR: |
| 112 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode], | 104 return gfx::Insets(kToolbarTopPadding[mode], kToolbarLeftPadding[mode], |
| 113 kToolbarBottomPadding[mode], | 105 kToolbarBottomPadding[mode], |
| 114 kToolbarRightPadding[mode]); | 106 kToolbarRightPadding[mode]); |
| 115 case TOOLBAR_BUTTON: | 107 case TOOLBAR_BUTTON: |
| 116 return gfx::Insets(kToolbarButtonPadding[mode]); | 108 return gfx::Insets(kToolbarButtonPadding[mode]); |
| 117 } | 109 } |
| 118 NOTREACHED(); | 110 NOTREACHED(); |
| 119 return gfx::Insets(); | 111 return gfx::Insets(); |
| 120 } | 112 } |
| 121 | 113 |
| 122 gfx::Size GetLayoutSize(LayoutSize size) { | 114 gfx::Size GetLayoutSize(LayoutSize size) { |
| 123 const int kNewTabButtonWidth[] = {34, 36, 39}; | 115 const int kNewTabButtonWidth[] = {36, 39}; |
| 124 const int kNewTabButtonHeight[] = {18, 18, 21}; | 116 const int kNewTabButtonHeight[] = {18, 21}; |
| 125 | 117 |
| 126 const int mode = ui::MaterialDesignController::GetMode(); | 118 const int mode = ui::MaterialDesignController::GetMode(); |
| 127 switch (size) { | 119 switch (size) { |
| 128 case NEW_TAB_BUTTON: | 120 case NEW_TAB_BUTTON: |
| 129 return gfx::Size(kNewTabButtonWidth[mode], kNewTabButtonHeight[mode]); | 121 return gfx::Size(kNewTabButtonWidth[mode], kNewTabButtonHeight[mode]); |
| 130 } | 122 } |
| 131 NOTREACHED(); | 123 NOTREACHED(); |
| 132 return gfx::Size(); | 124 return gfx::Size(); |
| 133 } | 125 } |
| OLD | NEW |