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

Side by Side Diff: chrome/browser/ui/views/harmony/harmony_typography_provider.cc

Issue 2910153002: Remove views::Label::SetDisabledColor(). Replace with typography colors. (Closed)
Patch Set: Use STYLE_HINT more. Fix SadTab Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/views/harmony/harmony_typography_provider.h" 5 #include "chrome/browser/ui/views/harmony/harmony_typography_provider.h"
6 6
7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" 7 #include "chrome/browser/ui/views/harmony/chrome_typography.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/color_palette.h"
9 #include "ui/gfx/platform_font.h" 10 #include "ui/gfx/platform_font.h"
11 #include "ui/native_theme/native_theme.h"
10 12
11 #if defined(USE_ASH) 13 #if defined(USE_ASH)
12 #include "ash/public/cpp/ash_typography.h" // nogncheck 14 #include "ash/public/cpp/ash_typography.h" // nogncheck
13 #endif 15 #endif
14 16
15 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context, 17 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context,
16 int text_style) const { 18 int text_style) const {
17 // "Target" font size constants from the Harmony spec. 19 // "Target" font size constants from the Harmony spec.
18 constexpr int kHeadlineSize = 20; 20 constexpr int kHeadlineSize = 20;
19 constexpr int kTitleSize = 15; 21 constexpr int kTitleSize = 15;
(...skipping 29 matching lines...) Expand all
49 default: 51 default:
50 break; 52 break;
51 } 53 }
52 54
53 // Ignore |text_style| since it only affects color in the Harmony spec. 55 // Ignore |text_style| since it only affects color in the Harmony spec.
54 56
55 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 57 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
56 size_delta, gfx::Font::NORMAL, font_weight); 58 size_delta, gfx::Font::NORMAL, font_weight);
57 } 59 }
58 60
59 SkColor HarmonyTypographyProvider::GetColor(int text_context, 61 SkColor HarmonyTypographyProvider::GetColor(
60 int text_style) const { 62 int text_context,
61 // TODO(tapted): Look up colors from the spec. 63 int text_style,
62 return SK_ColorBLACK; 64 const ui::NativeTheme& theme) const {
65 const SkColor foreground_color =
66 theme.GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor);
67
68 // If the default foreground color from the native theme isn't black, the rest
69 // of the Harmony spec isn't going to work. Just use the foreground color for
70 // text, with some exceptions.
71 if (foreground_color != SK_ColorBLACK) {
72 switch (text_style) {
Peter Kasting 2017/06/01 04:55:58 Seems like it might be OK to return the "red" and
tapted 2017/06/01 11:22:18 Done - Although I special-cased a white foreground
73 case views::style::STYLE_DISABLED:
74 case STYLE_SECONDARY:
75 case STYLE_HINT:
76 return theme.GetSystemColor(
77 ui::NativeTheme::kColorId_LabelDisabledColor);
78 case views::style::STYLE_LINK:
79 return theme.GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled);
80 }
81 return foreground_color;
82 }
83
84 switch (text_style) {
Peter Kasting 2017/06/01 04:55:58 Did you consider trying to implement these colors
tapted 2017/06/01 11:22:18 I didn't consider this.. But it might be overkill.
Peter Kasting 2017/06/01 19:08:01 Long-term, I'd like all the colors in all Chrome U
85 case views::style::STYLE_DIALOG_BUTTON_DEFAULT:
86 return SK_ColorWHITE;
87 case views::style::STYLE_DISABLED:
88 return SkColorSetRGB(0x9e, 0x9e, 0x9e);
89 case views::style::STYLE_LINK:
90 return gfx::kGoogleBlue700;
91 case STYLE_SECONDARY:
92 case STYLE_HINT:
93 return SkColorSetRGB(0x75, 0x75, 0x75);
94 case STYLE_RED:
95 return gfx::kGoogleRed700;
96 case STYLE_GREEN:
97 return gfx::kGoogleGreen700;
98 }
99 return SkColorSetRGB(0x21, 0x21, 0x21); // Primary for everything else.
63 } 100 }
64 101
65 int HarmonyTypographyProvider::GetLineHeight(int text_context, 102 int HarmonyTypographyProvider::GetLineHeight(int text_context,
66 int text_style) const { 103 int text_style) const {
67 // "Target" line height constants from the Harmony spec. A default OS 104 // "Target" line height constants from the Harmony spec. A default OS
68 // configuration should use these heights. However, if the user overrides OS 105 // configuration should use these heights. However, if the user overrides OS
69 // defaults, then GetLineHeight() should return the height that would add the 106 // defaults, then GetLineHeight() should return the height that would add the
70 // same extra space between lines as the default configuration would have. 107 // same extra space between lines as the default configuration would have.
71 constexpr int kHeadlineHeight = 32; 108 constexpr int kHeadlineHeight = 32;
72 constexpr int kTitleHeight = 22; 109 constexpr int kTitleHeight = 22;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 case views::style::CONTEXT_DIALOG_TITLE: 160 case views::style::CONTEXT_DIALOG_TITLE:
124 return title_height; 161 return title_height;
125 case CONTEXT_BODY_TEXT_LARGE: 162 case CONTEXT_BODY_TEXT_LARGE:
126 return body_large_height; 163 return body_large_height;
127 case CONTEXT_HEADLINE: 164 case CONTEXT_HEADLINE:
128 return headline_height; 165 return headline_height;
129 default: 166 default:
130 return default_height; 167 return default_height;
131 } 168 }
132 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698