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

Side by Side Diff: chrome/browser/themes/theme_properties.cc

Issue 1164333002: ToolbarView MaterialDesign in ThemeProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/themes/theme_properties.h" 5 #include "chrome/browser/themes/theme_properties.h"
6 6
7 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "chrome/browser/themes/browser_theme_pack.h" 11 #include "chrome/browser/themes/browser_theme_pack.h"
12 #include "chrome/common/chrome_switches.h"
11 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
12 #include "ui/resources/grit/ui_resources.h" 14 #include "ui/resources/grit/ui_resources.h"
13 15
14 namespace { 16 namespace {
15 17
16 // ---------------------------------------------------------------------------- 18 // ----------------------------------------------------------------------------
17 // Defaults for properties which are stored in the browser theme pack. If you 19 // Defaults for properties which are stored in the browser theme pack. If you
18 // change these defaults, you must increment the version number in 20 // change these defaults, you must increment the version number in
19 // browser_theme_pack.h 21 // browser_theme_pack.h
20 22
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #if defined(OS_MACOSX) 91 #if defined(OS_MACOSX)
90 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81); 92 const SkColor kDefaultColorToolbarButtonStroke = SkColorSetARGB(75, 81, 81, 81);
91 const SkColor kDefaultColorToolbarButtonStrokeInactive = 93 const SkColor kDefaultColorToolbarButtonStrokeInactive =
92 SkColorSetARGB(75, 99, 99, 99); 94 SkColorSetARGB(75, 99, 99, 99);
93 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); 95 const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204);
94 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); 96 const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103);
95 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163); 97 const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163);
96 #endif 98 #endif
97 99
98 // ---------------------------------------------------------------------------- 100 // ----------------------------------------------------------------------------
101 // Defaults for layout properties, which are not stored in the browser theme
102 // pack.
103
104 // The edge graphics have some built-in spacing/shadowing, so we have to adjust
105 // our spacing to make it match.
106 const int kToolbarViewLeftEdgeSpacing = 3;
107 const int kToolbarViewRightEdgeSpacing = 2;
108
109 // Ash doesn't use a rounded content area and its top edge has an extra shadow.
110 const int kToolbarViewContentShadowHeightAsh = 2;
111
112 // Non-ash uses a rounded content area with no shadow in the assets.
113 const int kToolbarViewContentShadowHeight = 0;
114
115 #if defined(ENABLE_TOPCHROME_MD)
116 const int kToolbarViewLeftEdgeSpacingMD = 8;
tdanderson 2015/06/09 15:32:38 For readability and accounting purposes, I'm tempt
jonross 2015/06/10 14:09:03 I personally prefer the compiler check. It acts as
117 const int kToolbarViewRightEdgeSpacingMD = 4;
118 const int kToolbarViewContentShadowHeightAshMD = 0;
119 const int kToolbarViewContentShadowHeightMD = 0;
120 #endif
121
122 // ----------------------------------------------------------------------------
99 123
100 // Strings used in alignment properties. 124 // Strings used in alignment properties.
101 const char kAlignmentCenter[] = "center"; 125 const char kAlignmentCenter[] = "center";
102 const char kAlignmentTop[] = "top"; 126 const char kAlignmentTop[] = "top";
103 const char kAlignmentBottom[] = "bottom"; 127 const char kAlignmentBottom[] = "bottom";
104 const char kAlignmentLeft[] = "left"; 128 const char kAlignmentLeft[] = "left";
105 const char kAlignmentRight[] = "right"; 129 const char kAlignmentRight[] = "right";
106 130
107 // Strings used in background tiling repetition properties. 131 // Strings used in background tiling repetition properties.
108 const char kTilingNoRepeat[] = "no-repeat"; 132 const char kTilingNoRepeat[] = "no-repeat";
(...skipping 19 matching lines...) Expand all
128 IDR_BROWSER_ACTIONS_OVERFLOW_P, 152 IDR_BROWSER_ACTIONS_OVERFLOW_P,
129 IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P, 153 IDR_TOOLS, IDR_TOOLS_H, IDR_TOOLS_P,
130 IDR_MENU_DROPARROW, 154 IDR_MENU_DROPARROW,
131 IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR, 155 IDR_TOOLBAR_BEZEL_HOVER, IDR_TOOLBAR_BEZEL_PRESSED, IDR_TOOLS_BAR,
132 }; 156 };
133 157
134 SkColor TintForUnderline(SkColor input) { 158 SkColor TintForUnderline(SkColor input) {
135 return SkColorSetA(input, SkColorGetA(input) / 3); 159 return SkColorSetA(input, SkColorGetA(input) / 3);
136 } 160 }
137 161
162 #if defined(ENABLE_TOPCHROME_MD)
163 int GetMaterialDefaultDisplayProperty(int id) {
164 switch (id) {
165 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING:
166 return kToolbarViewLeftEdgeSpacingMD;
167 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING:
168 return kToolbarViewRightEdgeSpacingMD;
169 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH:
170 return kToolbarViewContentShadowHeightAshMD;
171 case ThemeProperties::PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT:
172 return kToolbarViewContentShadowHeightMD;
173 }
174
175 return -1;
tdanderson 2015/06/09 15:32:38 This will be a problem if any of our constants are
tdanderson 2015/06/09 17:50:07 An example of a negative layout constant is kTabHo
jonross 2015/06/10 14:09:03 I've moved away from this. I've pulled the old pa
176 }
177 #endif
178
138 } // namespace 179 } // namespace
139 180
140 // static 181 // static
141 int ThemeProperties::StringToAlignment(const std::string& alignment) { 182 int ThemeProperties::StringToAlignment(const std::string& alignment) {
142 std::vector<std::string> split; 183 std::vector<std::string> split;
143 base::SplitStringAlongWhitespace(alignment, &split); 184 base::SplitStringAlongWhitespace(alignment, &split);
144 185
145 int alignment_mask = 0; 186 int alignment_mask = 0;
146 for (std::vector<std::string>::iterator component(split.begin()); 187 for (std::vector<std::string>::iterator component(split.begin());
147 component != split.end(); ++component) { 188 component != split.end(); ++component) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return kDefaultColorToolbarStrokeInactive; 333 return kDefaultColorToolbarStrokeInactive;
293 #endif 334 #endif
294 default: 335 default:
295 // Return a debugging red color. 336 // Return a debugging red color.
296 return SK_ColorRED; 337 return SK_ColorRED;
297 } 338 }
298 } 339 }
299 340
300 // static 341 // static
301 int ThemeProperties::GetDefaultDisplayProperty(int id) { 342 int ThemeProperties::GetDefaultDisplayProperty(int id) {
343 #if defined(ENABLE_TOPCHROME_MD)
344 bool material_design_enabled =
345 base::CommandLine::ForCurrentProcess()->HasSwitch(
346 switches::kTopChromeMDEnabled);
347 if (material_design_enabled) {
348 int property = GetMaterialDefaultDisplayProperty(id);
349 if (property != -1)
350 return property;
351 }
352 #endif
353
302 switch (id) { 354 switch (id) {
303 case NTP_BACKGROUND_ALIGNMENT: 355 case NTP_BACKGROUND_ALIGNMENT:
304 return kDefaultDisplayPropertyNTPAlignment; 356 return kDefaultDisplayPropertyNTPAlignment;
305 case NTP_BACKGROUND_TILING: 357 case NTP_BACKGROUND_TILING:
306 return kDefaultDisplayPropertyNTPTiling; 358 return kDefaultDisplayPropertyNTPTiling;
307 case NTP_LOGO_ALTERNATE: 359 case NTP_LOGO_ALTERNATE:
308 return kDefaultDisplayPropertyNTPAlternateLogo; 360 return kDefaultDisplayPropertyNTPAlternateLogo;
361 case PROPERTY_TOOLBAR_VIEW_LEFT_EDGE_SPACING:
362 return kToolbarViewLeftEdgeSpacing;
363 case PROPERTY_TOOLBAR_VIEW_RIGHT_EDGE_SPACING:
364 return kToolbarViewRightEdgeSpacing;
365 case PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT_ASH:
366 return kToolbarViewContentShadowHeightAsh;
367 case PROPERTY_TOOLBAR_VIEW_CONTENT_SHADOW_HEIGHT:
368 return kToolbarViewContentShadowHeight;
309 } 369 }
310 370
311 return -1; 371 return -1;
312 } 372 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_properties.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698