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

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: Using RGB macros for GTK colors 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"
11 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 11 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
12 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" 12 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
13 #include "ui/gfx/color_utils.h" 13 #include "ui/gfx/color_utils.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/path.h" 16 #include "ui/gfx/path.h"
17 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
18 #include "ui/native_theme/common_theme.h" 18 #include "ui/native_theme/common_theme.h"
19 19
20 namespace { 20 namespace {
21 21
22 // Theme colors returned by GetSystemColor(). 22 // Theme colors returned by GetSystemColor().
23 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); 23 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
24 24
25 const GdkColor kURLTextColor = GDK_COLOR_RGB(0x00, 0x88, 0x00); 25 const GdkColor kURLTextColor = GDK_COLOR_RGB(0x00, 0x88, 0x00);
26 const GdkColor kPositiveTextColor = GDK_COLOR_RGB(0x00, 0xff, 0x00);
Peter Kasting 2015/03/17 22:01:44 Nit: kURLTextColor is used in multiple functions a
dschuyler 2015/03/17 22:57:55 Done.
27 const GdkColor kNegativeTextColor = GDK_COLOR_RGB(0xff, 0x00, 0x00);
26 28
27 GdkColor GdkAlphaBlend(GdkColor foreground, 29 GdkColor GdkAlphaBlend(GdkColor foreground,
28 GdkColor background, 30 GdkColor background,
29 SkAlpha alpha) { 31 SkAlpha alpha) {
30 return libgtk2ui::SkColorToGdkColor( 32 return libgtk2ui::SkColorToGdkColor(
31 color_utils::AlphaBlend(libgtk2ui::GdkColorToSkColor(foreground), 33 color_utils::AlphaBlend(libgtk2ui::GdkColorToSkColor(foreground),
32 libgtk2ui::GdkColorToSkColor(background), alpha)); 34 libgtk2ui::GdkColorToSkColor(background), alpha));
33 } 35 }
34 36
35 // Generates the normal URL color, a green color used in unhighlighted URL 37 // Generates the normal URL color, a green color used in unhighlighted URL
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 // The luminance should match the luminance of the foreground text. Again, 89 // 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. 90 // we clamp so as to have at some amount of color (green) in the text.
89 double opposite_l = fg_hsl.l; 91 double opposite_l = fg_hsl.l;
90 double l = std::max(0.1, std::min(0.9, opposite_l)); 92 double l = std::max(0.1, std::min(0.9, opposite_l));
91 93
92 color_utils::HSL output = { hue_hsl.h, s, l }; 94 color_utils::HSL output = { hue_hsl.h, s, l };
93 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255)); 95 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255));
94 } 96 }
95 97
98 GdkColor GetReadableColor(const GdkColor& color, const GdkColor& background) {
99 return libgtk2ui::SkColorToGdkColor(
100 color_utils::GetReadableColor(libgtk2ui::GdkColorToSkColor(color),
101 libgtk2ui::GdkColorToSkColor(background)));
102 }
103
96 } // namespace 104 } // namespace
97 105
98 106
99 namespace libgtk2ui { 107 namespace libgtk2ui {
100 108
101 // static 109 // static
102 NativeThemeGtk2* NativeThemeGtk2::instance() { 110 NativeThemeGtk2* NativeThemeGtk2::instance() {
103 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ()); 111 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ());
104 return &s_native_theme; 112 return &s_native_theme;
105 } 113 }
(...skipping 260 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