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

Side by Side Diff: ui/native_theme/common_theme.cc

Issue 2413223003: Views:: Make Labels support text selection. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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
« no previous file with comments | « ui/gfx/render_text_mac.mm ('k') | ui/native_theme/native_theme.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/native_theme/common_theme.h" 5 #include "ui/native_theme/common_theme.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 SkColorSetRGB(0xA1, 0xA1, 0x92); 71 SkColorSetRGB(0xA1, 0xA1, 0x92);
72 static const SkColor kMenuBorderColor = SkColorSetRGB(0xBA, 0xBA, 0xBA); 72 static const SkColor kMenuBorderColor = SkColorSetRGB(0xBA, 0xBA, 0xBA);
73 static const SkColor kEnabledMenuButtonBorderColor = 73 static const SkColor kEnabledMenuButtonBorderColor =
74 SkColorSetA(SK_ColorBLACK, 0x24); 74 SkColorSetA(SK_ColorBLACK, 0x24);
75 static const SkColor kFocusedMenuButtonBorderColor = 75 static const SkColor kFocusedMenuButtonBorderColor =
76 SkColorSetA(SK_ColorBLACK, 0x48); 76 SkColorSetA(SK_ColorBLACK, 0x48);
77 static const SkColor kMenuSeparatorColor = SkColorSetRGB(0xE9, 0xE9, 0xE9); 77 static const SkColor kMenuSeparatorColor = SkColorSetRGB(0xE9, 0xE9, 0xE9);
78 static const SkColor kEnabledMenuItemForegroundColor = SK_ColorBLACK; 78 static const SkColor kEnabledMenuItemForegroundColor = SK_ColorBLACK;
79 // Link: 79 // Link:
80 static const SkColor kLinkEnabledColor = gfx::kGoogleBlue700; 80 static const SkColor kLinkEnabledColor = gfx::kGoogleBlue700;
81 // Text selection colors:
82 static const SkColor kTextSelectionBackgroundFocused =
83 SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
84 static const SkColor kTextSelectionColor = color_utils::AlphaBlend(
85 SK_ColorBLACK, kTextSelectionBackgroundFocused, 0xdd);
81 // Textfield: 86 // Textfield:
82 static const SkColor kTextfieldDefaultColor = SK_ColorBLACK; 87 static const SkColor kTextfieldDefaultColor = SK_ColorBLACK;
83 static const SkColor kTextfieldDefaultBackground = SK_ColorWHITE; 88 static const SkColor kTextfieldDefaultBackground = SK_ColorWHITE;
84 static const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY; 89 static const SkColor kTextfieldReadOnlyColor = SK_ColorDKGRAY;
85 static const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE; 90 static const SkColor kTextfieldReadOnlyBackground = SK_ColorWHITE;
86 static const SkColor kTextfieldSelectionBackgroundFocused =
87 SkColorSetARGB(0x54, 0x60, 0xA8, 0xEB);
88 static const SkColor kTextfieldSelectionColor = color_utils::AlphaBlend(
89 SK_ColorBLACK, kTextfieldSelectionBackgroundFocused, 0xdd);
90 // Results tables: 91 // Results tables:
91 static const SkColor kResultsTableText = SK_ColorBLACK; 92 static const SkColor kResultsTableText = SK_ColorBLACK;
92 static const SkColor kResultsTableDimmedText = 93 static const SkColor kResultsTableDimmedText =
93 SkColorSetRGB(0x64, 0x64, 0x64); 94 SkColorSetRGB(0x64, 0x64, 0x64);
94 static const SkColor kResultsTableHoveredBackground = color_utils::AlphaBlend( 95 static const SkColor kResultsTableHoveredBackground = color_utils::AlphaBlend(
95 kTextfieldSelectionBackgroundFocused, kTextfieldDefaultBackground, 0x40); 96 kTextSelectionBackgroundFocused, kTextfieldDefaultBackground, 0x40);
96 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); 97 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43);
97 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29); 98 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29);
98 static const SkColor kResultsTablePositiveText = color_utils::AlphaBlend( 99 static const SkColor kResultsTablePositiveText = color_utils::AlphaBlend(
99 kPositiveTextColor, kTextfieldDefaultBackground, 0xDD); 100 kPositiveTextColor, kTextfieldDefaultBackground, 0xDD);
100 static const SkColor kResultsTablePositiveHoveredText = 101 static const SkColor kResultsTablePositiveHoveredText =
101 color_utils::AlphaBlend(kPositiveTextColor, 102 color_utils::AlphaBlend(kPositiveTextColor,
102 kResultsTableHoveredBackground, 0xDD); 103 kResultsTableHoveredBackground, 0xDD);
103 static const SkColor kResultsTablePositiveSelectedText = 104 static const SkColor kResultsTablePositiveSelectedText =
104 color_utils::AlphaBlend(kPositiveTextColor, 105 color_utils::AlphaBlend(kPositiveTextColor,
105 kTextfieldSelectionBackgroundFocused, 0xDD); 106 kTextSelectionBackgroundFocused, 0xDD);
106 static const SkColor kResultsTableNegativeText = color_utils::AlphaBlend( 107 static const SkColor kResultsTableNegativeText = color_utils::AlphaBlend(
107 kNegativeTextColor, kTextfieldDefaultBackground, 0xDD); 108 kNegativeTextColor, kTextfieldDefaultBackground, 0xDD);
108 static const SkColor kResultsTableNegativeHoveredText = 109 static const SkColor kResultsTableNegativeHoveredText =
109 color_utils::AlphaBlend(kNegativeTextColor, 110 color_utils::AlphaBlend(kNegativeTextColor,
110 kResultsTableHoveredBackground, 0xDD); 111 kResultsTableHoveredBackground, 0xDD);
111 static const SkColor kResultsTableNegativeSelectedText = 112 static const SkColor kResultsTableNegativeSelectedText =
112 color_utils::AlphaBlend(kNegativeTextColor, 113 color_utils::AlphaBlend(kNegativeTextColor,
113 kTextfieldSelectionBackgroundFocused, 0xDD); 114 kTextSelectionBackgroundFocused, 0xDD);
114 // Tooltip: 115 // Tooltip:
115 static const SkColor kTooltipBackground = SkColorSetA(SK_ColorBLACK, 0xCC); 116 static const SkColor kTooltipBackground = SkColorSetA(SK_ColorBLACK, 0xCC);
116 static const SkColor kTooltipTextColor = SkColorSetA(SK_ColorWHITE, 0xDE); 117 static const SkColor kTooltipTextColor = SkColorSetA(SK_ColorWHITE, 0xDE);
117 // Tree: 118 // Tree:
118 static const SkColor kTreeBackground = SK_ColorWHITE; 119 static const SkColor kTreeBackground = SK_ColorWHITE;
119 static const SkColor kTreeTextColor = SK_ColorBLACK; 120 static const SkColor kTreeTextColor = SK_ColorBLACK;
120 static const SkColor kTreeSelectedTextColor = SK_ColorBLACK; 121 static const SkColor kTreeSelectedTextColor = SK_ColorBLACK;
121 static const SkColor kTreeSelectionBackgroundColor = 122 static const SkColor kTreeSelectionBackgroundColor =
122 SkColorSetRGB(0xEE, 0xEE, 0xEE); 123 SkColorSetRGB(0xEE, 0xEE, 0xEE);
123 static const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A); 124 static const SkColor kTreeArrowColor = SkColorSetRGB(0x7A, 0x7A, 0x7A);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return kEnabledMenuItemForegroundColor; 183 return kEnabledMenuItemForegroundColor;
183 case NativeTheme::kColorId_DisabledMenuItemForegroundColor: 184 case NativeTheme::kColorId_DisabledMenuItemForegroundColor:
184 return kDisabledMenuItemForegroundColor; 185 return kDisabledMenuItemForegroundColor;
185 186
186 // Label 187 // Label
187 case NativeTheme::kColorId_LabelEnabledColor: 188 case NativeTheme::kColorId_LabelEnabledColor:
188 return kButtonEnabledColor; 189 return kButtonEnabledColor;
189 case NativeTheme::kColorId_LabelDisabledColor: 190 case NativeTheme::kColorId_LabelDisabledColor:
190 return base_theme->GetSystemColor( 191 return base_theme->GetSystemColor(
191 NativeTheme::kColorId_ButtonDisabledColor); 192 NativeTheme::kColorId_ButtonDisabledColor);
193 case NativeTheme::kColorId_LabelTextSelectionColor:
194 return kTextSelectionColor;
195 case NativeTheme::kColorId_LabelTextSelectionBackgroundFocused:
196 return kTextSelectionBackgroundFocused;
192 197
193 // Link 198 // Link
194 // TODO(estade): where, if anywhere, do we use disabled links in Chrome? 199 // TODO(estade): where, if anywhere, do we use disabled links in Chrome?
195 case NativeTheme::kColorId_LinkDisabled: 200 case NativeTheme::kColorId_LinkDisabled:
196 return SK_ColorBLACK; 201 return SK_ColorBLACK;
197 202
198 case NativeTheme::kColorId_LinkEnabled: 203 case NativeTheme::kColorId_LinkEnabled:
199 case NativeTheme::kColorId_LinkPressed: 204 case NativeTheme::kColorId_LinkPressed:
200 return kLinkEnabledColor; 205 return kLinkEnabledColor;
201 206
202 // Textfield 207 // Textfield
203 case NativeTheme::kColorId_TextfieldDefaultColor: 208 case NativeTheme::kColorId_TextfieldDefaultColor:
204 return kTextfieldDefaultColor; 209 return kTextfieldDefaultColor;
205 case NativeTheme::kColorId_TextfieldDefaultBackground: 210 case NativeTheme::kColorId_TextfieldDefaultBackground:
206 return kTextfieldDefaultBackground; 211 return kTextfieldDefaultBackground;
207 case NativeTheme::kColorId_TextfieldReadOnlyColor: 212 case NativeTheme::kColorId_TextfieldReadOnlyColor:
208 return kTextfieldReadOnlyColor; 213 return kTextfieldReadOnlyColor;
209 case NativeTheme::kColorId_TextfieldReadOnlyBackground: 214 case NativeTheme::kColorId_TextfieldReadOnlyBackground:
210 return kTextfieldReadOnlyBackground; 215 return kTextfieldReadOnlyBackground;
211 case NativeTheme::kColorId_TextfieldSelectionColor: 216 case NativeTheme::kColorId_TextfieldSelectionColor:
212 return kTextfieldSelectionColor; 217 return kTextSelectionColor;
213 case NativeTheme::kColorId_TextfieldSelectionBackgroundFocused: 218 case NativeTheme::kColorId_TextfieldSelectionBackgroundFocused:
214 return kTextfieldSelectionBackgroundFocused; 219 return kTextSelectionBackgroundFocused;
215 220
216 // Tooltip 221 // Tooltip
217 case NativeTheme::kColorId_TooltipBackground: 222 case NativeTheme::kColorId_TooltipBackground:
218 return kTooltipBackground; 223 return kTooltipBackground;
219 case NativeTheme::kColorId_TooltipText: 224 case NativeTheme::kColorId_TooltipText:
220 return kTooltipTextColor; 225 return kTooltipTextColor;
221 226
222 // Tree 227 // Tree
223 case NativeTheme::kColorId_TreeBackground: 228 case NativeTheme::kColorId_TreeBackground:
224 return kTreeBackground; 229 return kTreeBackground;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 341 }
337 if (menu_item.corner_radius > 0) { 342 if (menu_item.corner_radius > 0) {
338 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); 343 const SkScalar radius = SkIntToScalar(menu_item.corner_radius);
339 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); 344 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint);
340 return; 345 return;
341 } 346 }
342 canvas->drawRect(gfx::RectToSkRect(rect), paint); 347 canvas->drawRect(gfx::RectToSkRect(rect), paint);
343 } 348 }
344 349
345 } // namespace ui 350 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/render_text_mac.mm ('k') | ui/native_theme/native_theme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698