| OLD | NEW |
| 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 Loading... |
| 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(SkColor color, const GdkColor& background) { |
| 98 return libgtk2ui::SkColorToGdkColor(color_utils::GetReadableColor( |
| 99 color, 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 case kColorId_ResultsTableHoveredDivider: { | 372 case kColorId_ResultsTableHoveredDivider: { |
| 367 GtkStyle* win_style = GetWindowStyle(); | 373 GtkStyle* win_style = GetWindowStyle(); |
| 368 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT], | 374 return GdkAlphaBlend(win_style->text[GTK_STATE_PRELIGHT], |
| 369 win_style->bg[GTK_STATE_PRELIGHT], 0x34); | 375 win_style->bg[GTK_STATE_PRELIGHT], 0x34); |
| 370 } | 376 } |
| 371 case kColorId_ResultsTableSelectedDivider: { | 377 case kColorId_ResultsTableSelectedDivider: { |
| 372 GtkStyle* win_style = GetWindowStyle(); | 378 GtkStyle* win_style = GetWindowStyle(); |
| 373 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED], | 379 return GdkAlphaBlend(win_style->text[GTK_STATE_SELECTED], |
| 374 win_style->bg[GTK_STATE_SELECTED], 0x34); | 380 win_style->bg[GTK_STATE_SELECTED], 0x34); |
| 375 } | 381 } |
| 382 case kColorId_ResultsTablePositiveText: { |
| 383 return GetReadableColor(SK_ColorGREEN, |
| 384 GetEntryStyle()->base[GTK_STATE_NORMAL]); |
| 385 } |
| 386 case kColorId_ResultsTablePositiveHoveredText: { |
| 387 return GetReadableColor(SK_ColorGREEN, |
| 388 GetEntryStyle()->base[GTK_STATE_PRELIGHT]); |
| 389 } |
| 390 case kColorId_ResultsTablePositiveSelectedText: { |
| 391 return GetReadableColor(SK_ColorGREEN, |
| 392 GetEntryStyle()->base[GTK_STATE_SELECTED]); |
| 393 } |
| 394 case kColorId_ResultsTableNegativeText: { |
| 395 return GetReadableColor(SK_ColorRED, |
| 396 GetEntryStyle()->base[GTK_STATE_NORMAL]); |
| 397 } |
| 398 case kColorId_ResultsTableNegativeHoveredText: { |
| 399 return GetReadableColor(SK_ColorRED, |
| 400 GetEntryStyle()->base[GTK_STATE_PRELIGHT]); |
| 401 } |
| 402 case kColorId_ResultsTableNegativeSelectedText: { |
| 403 return GetReadableColor(SK_ColorRED, |
| 404 GetEntryStyle()->base[GTK_STATE_SELECTED]); |
| 405 } |
| 376 case kColorId_NumColors: | 406 case kColorId_NumColors: |
| 377 NOTREACHED(); | 407 NOTREACHED(); |
| 378 break; | 408 break; |
| 379 } | 409 } |
| 380 | 410 |
| 381 return SkColorToGdkColor(kInvalidColorIdColor); | 411 return SkColorToGdkColor(kInvalidColorIdColor); |
| 382 } | 412 } |
| 383 | 413 |
| 384 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { | 414 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { |
| 385 if (!fake_window_) { | 415 if (!fake_window_) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 0, 0, | 516 0, 0, |
| 487 rect.width(), rect.height()); | 517 rect.width(), rect.height()); |
| 488 SkBitmap arrow = GdkPixbufToImageSkia(pb); | 518 SkBitmap arrow = GdkPixbufToImageSkia(pb); |
| 489 canvas->drawBitmap(arrow, rect.x(), rect.y()); | 519 canvas->drawBitmap(arrow, rect.x(), rect.y()); |
| 490 | 520 |
| 491 g_object_unref(pb); | 521 g_object_unref(pb); |
| 492 g_object_unref(pm); | 522 g_object_unref(pm); |
| 493 } | 523 } |
| 494 | 524 |
| 495 } // namespace libgtk2ui | 525 } // namespace libgtk2ui |
| OLD | NEW |