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

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 SK color macros 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 "third_party/skia/include/core/SkColor.h"
13 #include "ui/gfx/color_utils.h" 14 #include "ui/gfx/color_utils.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/path.h" 17 #include "ui/gfx/path.h"
17 #include "ui/gfx/skia_util.h" 18 #include "ui/gfx/skia_util.h"
18 #include "ui/native_theme/common_theme.h" 19 #include "ui/native_theme/common_theme.h"
19 20
20 namespace { 21 namespace {
21 22
22 // Theme colors returned by GetSystemColor(). 23 // Theme colors returned by GetSystemColor().
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 // The luminance should match the luminance of the foreground text. Again, 88 // 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. 89 // we clamp so as to have at some amount of color (green) in the text.
89 double opposite_l = fg_hsl.l; 90 double opposite_l = fg_hsl.l;
90 double l = std::max(0.1, std::min(0.9, opposite_l)); 91 double l = std::max(0.1, std::min(0.9, opposite_l));
91 92
92 color_utils::HSL output = { hue_hsl.h, s, l }; 93 color_utils::HSL output = { hue_hsl.h, s, l };
93 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255)); 94 return libgtk2ui::SkColorToGdkColor(color_utils::HSLToSkColor(output, 255));
94 } 95 }
95 96
97 GdkColor GetReadableColor(const SkColor& color, const GdkColor& background) {
Peter Kasting 2015/03/18 02:10:35 Nit: Pass SkColor by value as it's a uint32_t.
dschuyler 2015/03/18 03:59:52 Done.
98 return libgtk2ui::SkColorToGdkColor(
99 color_utils::GetReadableColor(color,
100 libgtk2ui::GdkColorToSkColor(background)));
101 }
102
96 } // namespace 103 } // namespace
97 104
98 105
99 namespace libgtk2ui { 106 namespace libgtk2ui {
100 107
101 // static 108 // static
102 NativeThemeGtk2* NativeThemeGtk2::instance() { 109 NativeThemeGtk2* NativeThemeGtk2::instance() {
103 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ()); 110 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ());
104 return &s_native_theme; 111 return &s_native_theme;
105 } 112 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 case kColorId_ResultsTableHoveredDivider: { 373 case kColorId_ResultsTableHoveredDivider: {
367 GtkStyle* win_style = GetWindowStyle(); 374 GtkStyle* win_style = GetWindowStyle();
368 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT], 375 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT],
369 win_style->bg[GTK_STATE_PRELIGHT], 0x34); 376 win_style->bg[GTK_STATE_PRELIGHT], 0x34);
370 } 377 }
371 case kColorId_ResultsTableSelectedDivider: { 378 case kColorId_ResultsTableSelectedDivider: {
372 GtkStyle* win_style = GetWindowStyle(); 379 GtkStyle* win_style = GetWindowStyle();
373 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED], 380 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED],
374 win_style->bg[GTK_STATE_SELECTED], 0x34); 381 win_style->bg[GTK_STATE_SELECTED], 0x34);
375 } 382 }
383 case kColorId_ResultsTablePositiveText: {
384 return GetReadableColor(SK_ColorGREEN,
385 GetEntryStyle()->base[GTK_STATE_NORMAL]);
386 }
387 case kColorId_ResultsTablePositiveHoveredText: {
388 return GetReadableColor(SK_ColorGREEN,
389 GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
390 }
391 case kColorId_ResultsTablePositiveSelectedText: {
392 return GetReadableColor(SK_ColorGREEN,
393 GetEntryStyle()->base[GTK_STATE_SELECTED]);
394 }
395 case kColorId_ResultsTableNegativeText: {
396 return GetReadableColor(SK_ColorRED,
397 GetEntryStyle()->base[GTK_STATE_NORMAL]);
398 }
399 case kColorId_ResultsTableNegativeHoveredText: {
400 return GetReadableColor(SK_ColorRED,
401 GetEntryStyle()->base[GTK_STATE_PRELIGHT]);
402 }
403 case kColorId_ResultsTableNegativeSelectedText: {
404 return GetReadableColor(SK_ColorRED,
405 GetEntryStyle()->base[GTK_STATE_SELECTED]);
406 }
376 case kColorId_NumColors: 407 case kColorId_NumColors:
377 NOTREACHED(); 408 NOTREACHED();
378 break; 409 break;
379 } 410 }
380 411
381 return SkColorToGdkColor(kInvalidColorIdColor); 412 return SkColorToGdkColor(kInvalidColorIdColor);
382 } 413 }
383 414
384 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { 415 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const {
385 if (!fake_window_) { 416 if (!fake_window_) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 0, 0, 517 0, 0,
487 rect.width(), rect.height()); 518 rect.width(), rect.height());
488 SkBitmap arrow = GdkPixbufToImageSkia(pb); 519 SkBitmap arrow = GdkPixbufToImageSkia(pb);
489 canvas->drawBitmap(arrow, rect.x(), rect.y()); 520 canvas->drawBitmap(arrow, rect.x(), rect.y());
490 521
491 g_object_unref(pb); 522 g_object_unref(pb);
492 g_object_unref(pm); 523 g_object_unref(pm);
493 } 524 }
494 525
495 } // namespace libgtk2ui 526 } // namespace libgtk2ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698