| 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[] = {6, 6}; | 12 const bool hybrid = ui::MaterialDesignController::GetMode() == |
| 13 const int kLocationBarBorderThickness[] = {1, 1}; | 13 ui::MaterialDesignController::MATERIAL_HYBRID; |
| 14 const int kLocationBarBubbleFontVerticalPadding[] = {2, 4}; | |
| 15 const int kLocationBarBubbleVerticalPadding[] = {3, 3}; | |
| 16 const int kLocationBarBubbleAnchorVerticalInset[] = {6, 8}; | |
| 17 const int kLocationBarHeight[] = {28, 32}; | |
| 18 const int kLocationBarHorizontalPadding[] = {6, 6}; | |
| 19 const int kLocationBarVerticalPadding[] = {1, 1}; | |
| 20 const int kOmniboxFontPixelSize[] = {14, 14}; | |
| 21 const int kTabFaviconTitleSpacing[] = {6, 6}; | |
| 22 const int kTabHeight[] = {29, 33}; | |
| 23 const int kTabPinnedContentWidth[] = {23, 23}; | |
| 24 const int kTabstripNewTabButtonOverlap[] = {5, 6}; | |
| 25 const int kTabstripTabOverlap[] = {16, 16}; | |
| 26 const int kToolbarStandardSpacing[] = {4, 8}; | |
| 27 const int kToolbarElementPadding[] = {0, 8}; | |
| 28 const int kToolbarLocationBarRightPadding[] = {4, 8}; | |
| 29 | |
| 30 const int mode = ui::MaterialDesignController::GetMode(); | |
| 31 switch (constant) { | 14 switch (constant) { |
| 32 case AVATAR_ICON_PADDING: | |
| 33 return 4; | |
| 34 case FIND_BAR_TOOLBAR_OVERLAP: | |
| 35 return kFindBarVerticalOffset[mode]; | |
| 36 case LOCATION_BAR_BORDER_THICKNESS: | |
| 37 return kLocationBarBorderThickness[mode]; | |
| 38 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING: | 15 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING: |
| 39 return kLocationBarBubbleFontVerticalPadding[mode]; | 16 return hybrid ? 4 : 2; |
| 40 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: | |
| 41 return kLocationBarBubbleVerticalPadding[mode]; | |
| 42 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET: | 17 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET: |
| 43 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 18 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 44 return 1; | 19 return 1; |
| 45 return kLocationBarBubbleAnchorVerticalInset[mode]; | 20 return hybrid ? 8 : 6; |
| 46 case LOCATION_BAR_HEIGHT: | 21 case LOCATION_BAR_HEIGHT: |
| 47 return kLocationBarHeight[mode]; | 22 return hybrid ? 32 : 28; |
| 48 case LOCATION_BAR_HORIZONTAL_PADDING: | |
| 49 return kLocationBarHorizontalPadding[mode]; | |
| 50 case LOCATION_BAR_VERTICAL_PADDING: | |
| 51 return kLocationBarVerticalPadding[mode]; | |
| 52 case OMNIBOX_FONT_PIXEL_SIZE: | |
| 53 return kOmniboxFontPixelSize[mode]; | |
| 54 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: | 23 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: |
| 55 return kTabstripNewTabButtonOverlap[mode]; | 24 return hybrid ? 6 : 5; |
| 56 case TABSTRIP_TAB_OVERLAP: | |
| 57 return kTabstripTabOverlap[mode]; | |
| 58 case TAB_FAVICON_TITLE_SPACING: | |
| 59 return kTabFaviconTitleSpacing[mode]; | |
| 60 case TAB_HEIGHT: | 25 case TAB_HEIGHT: |
| 61 return kTabHeight[mode]; | 26 return hybrid ? 33 : 29; |
| 62 case TAB_PINNED_CONTENT_WIDTH: | |
| 63 return kTabPinnedContentWidth[mode]; | |
| 64 case TOOLBAR_BUTTON_PADDING: | |
| 65 return 6; | |
| 66 case TOOLBAR_ELEMENT_PADDING: | 27 case TOOLBAR_ELEMENT_PADDING: |
| 67 return kToolbarElementPadding[mode]; | 28 return hybrid ? 8 : 0; |
| 68 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING: | |
| 69 return kToolbarLocationBarRightPadding[mode]; | |
| 70 case TOOLBAR_STANDARD_SPACING: | 29 case TOOLBAR_STANDARD_SPACING: |
| 71 return kToolbarStandardSpacing[mode]; | 30 return hybrid ? 8 : 4; |
| 72 } | 31 } |
| 73 NOTREACHED(); | 32 NOTREACHED(); |
| 74 return 0; | 33 return 0; |
| 75 } | 34 } |
| 76 | 35 |
| 77 gfx::Insets GetLayoutInsets(LayoutInset inset) { | 36 gfx::Insets GetLayoutInsets(LayoutInset inset) { |
| 37 const bool hybrid = ui::MaterialDesignController::GetMode() == |
| 38 ui::MaterialDesignController::MATERIAL_HYBRID; |
| 78 switch (inset) { | 39 switch (inset) { |
| 79 case TAB: { | 40 case TAB: |
| 80 const bool hybrid = ui::MaterialDesignController::GetMode() == | |
| 81 ui::MaterialDesignController::MATERIAL_HYBRID; | |
| 82 return gfx::Insets(1, hybrid ? 18 : 16); | 41 return gfx::Insets(1, hybrid ? 18 : 16); |
| 83 } | |
| 84 } | 42 } |
| 85 NOTREACHED(); | 43 NOTREACHED(); |
| 86 return gfx::Insets(); | 44 return gfx::Insets(); |
| 87 } | 45 } |
| 88 | 46 |
| 89 gfx::Size GetLayoutSize(LayoutSize size) { | 47 gfx::Size GetLayoutSize(LayoutSize size) { |
| 90 const int kNewTabButtonWidth[] = {36, 39}; | 48 const bool hybrid = ui::MaterialDesignController::GetMode() == |
| 91 const int kNewTabButtonHeight[] = {18, 21}; | 49 ui::MaterialDesignController::MATERIAL_HYBRID; |
| 92 | |
| 93 const int mode = ui::MaterialDesignController::GetMode(); | |
| 94 switch (size) { | 50 switch (size) { |
| 95 case NEW_TAB_BUTTON: | 51 case NEW_TAB_BUTTON: |
| 96 return gfx::Size(kNewTabButtonWidth[mode], kNewTabButtonHeight[mode]); | 52 return hybrid ? gfx::Size(39, 21) : gfx::Size(36, 18); |
| 97 } | 53 } |
| 98 NOTREACHED(); | 54 NOTREACHED(); |
| 99 return gfx::Size(); | 55 return gfx::Size(); |
| 100 } | 56 } |
| OLD | NEW |