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

Side by Side Diff: chrome/browser/ui/libgtk2ui/native_theme_gtk2.cc

Issue 795933009: [AiS] for desktop, two lines and font sytles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge from master Created 5 years, 9 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/ui/libgtk2ui/native_theme_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/native_theme_gtk2.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_menu_subclasses.h" 9 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_menu_subclasses.h"
10 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" 10 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // The luminance should match the luminance of the foreground text. Again, 87 // The luminance should match the luminance of the foreground text. Again,
88 // we clamp so as to have at some amount of color (green) in the text. 88 // we clamp so as to have at some amount of color (green) in the text.
89 double opposite_l = fg_hsl.l; 89 double opposite_l = fg_hsl.l;
90 double l = std::max(0.1, std::min(0.9, opposite_l)); 90 double l = std::max(0.1, std::min(0.9, opposite_l));
91 91
92 color_utils::HSL output = { hue_hsl.h, s, l }; 92 color_utils::HSL output = { hue_hsl.h, s, l };
93 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255)); 93 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255));
94 } 94 }
95 95
96 GdkColor GetReadableColor(const GdkColor& color, const GdkColor& background) {
97 return libgtk2ui::SkColorToGdkColor(
98 color_utils::GetReadableColor(libgtk2ui::GdkColorToSkColor(color),
99 libgtk2ui::GdkColorToSkColor(background)));
100 }
101
96 } // namespace 102 } // namespace
97 103
98 104
99 namespace libgtk2ui { 105 namespace libgtk2ui {
100 106
101 // static 107 // static
102 NativeThemeGtk2* NativeThemeGtk2::instance() { 108 NativeThemeGtk2* NativeThemeGtk2::instance() {
103 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ()); 109 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ());
104 return &s_native_theme; 110 return &s_native_theme;
105 } 111 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 paint.setColor(color); 207 paint.setColor(color);
202 break; 208 break;
203 default: 209 default:
204 NOTREACHED() << "Invalid state " << state; 210 NOTREACHED() << "Invalid state " << state;
205 break; 211 break;
206 } 212 }
207 canvas->drawRect(gfx::RectToSkRect(rect), paint); 213 canvas->drawRect(gfx::RectToSkRect(rect), paint);
208 } 214 }
209 215
210 GdkColor NativeThemeGtk2::GetSystemGdkColor(ColorId color_id) const { 216 GdkColor NativeThemeGtk2::GetSystemGdkColor(ColorId color_id) const {
217 const GdkColor kPositiveTextColor = GDK_COLOR_RGB(0x00, 0xff, 0x00);
218 const GdkColor kNegativeTextColor = GDK_COLOR_RGB(0xff, 0x00, 0x00);
Peter Kasting 2015/03/18 00:36:19 I didn't notice this before, but: You can actuall
dschuyler 2015/03/18 01:19:35 Done.
211 switch (color_id) { 219 switch (color_id) {
212 // Windows 220 // Windows
213 case kColorId_WindowBackground: 221 case kColorId_WindowBackground:
214 return GetWindowStyle()->bg[GTK_STATE_NORMAL]; 222 return GetWindowStyle()->bg[GTK_STATE_NORMAL];
215 223
216 // Dialogs 224 // Dialogs
217 case kColorId_DialogBackground: 225 case kColorId_DialogBackground:
218 return GetWindowStyle()->bg[GTK_STATE_NORMAL]; 226 return GetWindowStyle()->bg[GTK_STATE_NORMAL];
219 227
220 // FocusableBorder 228 // FocusableBorder
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 case kColorId_ResultsTableHoveredDivider: { 374 case kColorId_ResultsTableHoveredDivider: {
367 GtkStyle* win_style = GetWindowStyle(); 375 GtkStyle* win_style = GetWindowStyle();
368 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT], 376 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT],
369 win_style->bg[GTK_STATE_PRELIGHT], 0x34); 377 win_style->bg[GTK_STATE_PRELIGHT], 0x34);
370 } 378 }
371 case kColorId_ResultsTableSelectedDivider: { 379 case kColorId_ResultsTableSelectedDivider: {
372 GtkStyle* win_style = GetWindowStyle(); 380 GtkStyle* win_style = GetWindowStyle();
373 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED], 381 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED],
374 win_style->bg[GTK_STATE_SELECTED], 0x34); 382 win_style->bg[GTK_STATE_SELECTED], 0x34);
375 } 383 }
384 case kColorId_ResultsTablePositiveText: {
385 return GetReadableColor(kPositiveTextColor,
386 GetEntryStyle()->base[GTK_STATE_NORMAL]);
387 }
388 case kColorId_ResultsTablePositiveHoveredText: {
389 return GetReadableColor(kPositiveTextColor,
390 GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
391 }
392 case kColorId_ResultsTablePositiveSelectedText: {
393 return GetReadableColor(kPositiveTextColor,
394 GetEntryStyle()->base[GTK_STATE_SELECTED]);
395 }
396 case kColorId_ResultsTableNegativeText: {
397 return GetReadableColor(kNegativeTextColor,
398 GetEntryStyle()->base[GTK_STATE_NORMAL]);
399 }
400 case kColorId_ResultsTableNegativeHoveredText: {
401 return GetReadableColor(kNegativeTextColor,
402 GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
403 }
404 case kColorId_ResultsTableNegativeSelectedText: {
405 return GetReadableColor(kNegativeTextColor,
406 GetEntryStyle()->base[GTK_STATE_SELECTED]);
407 }
376 case kColorId_NumColors: 408 case kColorId_NumColors:
377 NOTREACHED(); 409 NOTREACHED();
378 break; 410 break;
379 } 411 }
380 412
381 return SkColorToGdkColor(kInvalidColorIdColor); 413 return SkColorToGdkColor(kInvalidColorIdColor);
382 } 414 }
383 415
384 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { 416 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const {
385 if (!fake_window_) { 417 if (!fake_window_) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 0, 0, 518 0, 0,
487 rect.width(), rect.height()); 519 rect.width(), rect.height());
488 SkBitmap arrow = GdkPixbufToImageSkia(pb); 520 SkBitmap arrow = GdkPixbufToImageSkia(pb);
489 canvas->drawBitmap(arrow, rect.x(), rect.y()); 521 canvas->drawBitmap(arrow, rect.x(), rect.y());
490 522
491 g_object_unref(pb); 523 g_object_unref(pb);
492 g_object_unref(pm); 524 g_object_unref(pm);
493 } 525 }
494 526
495 } // namespace libgtk2ui 527 } // namespace libgtk2ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698