Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/browser/ui/layout_constants.cc

Issue 2555623002: Last round of cleaning up MD layout constants. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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: 15 case AVATAR_ICON_PADDING:
33 return 4; 16 return 4;
Peter Kasting 2016/12/06 04:12:24 Usually with these constants that don't depend on
Evan Stade 2016/12/08 15:34:44 not really. Moved.
34 case FIND_BAR_TOOLBAR_OVERLAP:
35 return kFindBarVerticalOffset[mode];
36 case LOCATION_BAR_BORDER_THICKNESS: 17 case LOCATION_BAR_BORDER_THICKNESS:
37 return kLocationBarBorderThickness[mode]; 18 return 1;
38 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING: 19 case LOCATION_BAR_BUBBLE_FONT_VERTICAL_PADDING:
39 return kLocationBarBubbleFontVerticalPadding[mode]; 20 return hybrid ? 4 : 2;
40 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING: 21 case LOCATION_BAR_BUBBLE_VERTICAL_PADDING:
41 return kLocationBarBubbleVerticalPadding[mode]; 22 return 3;
42 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET: 23 case LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET:
43 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) 24 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
44 return 1; 25 return 1;
45 return kLocationBarBubbleAnchorVerticalInset[mode]; 26 return hybrid ? 8 : 6;
46 case LOCATION_BAR_HEIGHT: 27 case LOCATION_BAR_HEIGHT:
47 return kLocationBarHeight[mode]; 28 return hybrid ? 32 : 28;
48 case LOCATION_BAR_HORIZONTAL_PADDING: 29 case LOCATION_BAR_HORIZONTAL_PADDING:
49 return kLocationBarHorizontalPadding[mode]; 30 return 6;
50 case LOCATION_BAR_VERTICAL_PADDING: 31 case LOCATION_BAR_VERTICAL_PADDING:
51 return kLocationBarVerticalPadding[mode]; 32 return 1;
52 case OMNIBOX_FONT_PIXEL_SIZE:
53 return kOmniboxFontPixelSize[mode];
54 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP: 33 case TABSTRIP_NEW_TAB_BUTTON_OVERLAP:
55 return kTabstripNewTabButtonOverlap[mode]; 34 return hybrid ? 6 : 5;
56 case TABSTRIP_TAB_OVERLAP: 35 case TABSTRIP_TAB_OVERLAP:
57 return kTabstripTabOverlap[mode]; 36 return 16;
58 case TAB_FAVICON_TITLE_SPACING:
59 return kTabFaviconTitleSpacing[mode];
60 case TAB_HEIGHT: 37 case TAB_HEIGHT:
61 return kTabHeight[mode]; 38 return hybrid ? 33 : 29;
62 case TAB_PINNED_CONTENT_WIDTH:
63 return kTabPinnedContentWidth[mode];
64 case TOOLBAR_BUTTON_PADDING: 39 case TOOLBAR_BUTTON_PADDING:
65 return 6; 40 return 6;
66 case TOOLBAR_ELEMENT_PADDING: 41 case TOOLBAR_ELEMENT_PADDING:
67 return kToolbarElementPadding[mode]; 42 return hybrid ? 8 : 0;
68 case TOOLBAR_LOCATION_BAR_RIGHT_PADDING:
69 return kToolbarLocationBarRightPadding[mode];
70 case TOOLBAR_STANDARD_SPACING: 43 case TOOLBAR_STANDARD_SPACING:
71 return kToolbarStandardSpacing[mode]; 44 return hybrid ? 8 : 4;
72 } 45 }
73 NOTREACHED(); 46 NOTREACHED();
74 return 0; 47 return 0;
75 } 48 }
76 49
77 gfx::Insets GetLayoutInsets(LayoutInset inset) { 50 gfx::Insets GetLayoutInsets(LayoutInset inset) {
51 const bool hybrid = ui::MaterialDesignController::GetMode() ==
52 ui::MaterialDesignController::MATERIAL_HYBRID;
78 switch (inset) { 53 switch (inset) {
79 case TAB: { 54 case TAB:
80 const bool hybrid = ui::MaterialDesignController::GetMode() ==
81 ui::MaterialDesignController::MATERIAL_HYBRID;
82 return gfx::Insets(1, hybrid ? 18 : 16); 55 return gfx::Insets(1, hybrid ? 18 : 16);
83 }
84 } 56 }
85 NOTREACHED(); 57 NOTREACHED();
86 return gfx::Insets(); 58 return gfx::Insets();
87 } 59 }
88 60
89 gfx::Size GetLayoutSize(LayoutSize size) { 61 gfx::Size GetLayoutSize(LayoutSize size) {
90 const int kNewTabButtonWidth[] = {36, 39}; 62 const bool hybrid = ui::MaterialDesignController::GetMode() ==
91 const int kNewTabButtonHeight[] = {18, 21}; 63 ui::MaterialDesignController::MATERIAL_HYBRID;
92
93 const int mode = ui::MaterialDesignController::GetMode();
94 switch (size) { 64 switch (size) {
95 case NEW_TAB_BUTTON: 65 case NEW_TAB_BUTTON:
96 return gfx::Size(kNewTabButtonWidth[mode], kNewTabButtonHeight[mode]); 66 return gfx::Size(hybrid ? 39 : 36, hybrid ? 21 : 18);
Peter Kasting 2016/12/06 04:12:24 Nit: Slightly longer, but seems easier to read:
Evan Stade 2016/12/08 15:34:44 Done.
97 } 67 }
98 NOTREACHED(); 68 NOTREACHED();
99 return gfx::Size(); 69 return gfx::Size();
100 } 70 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/layout_constants.h ('k') | chrome/browser/ui/views/frame/browser_view_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698