Chromium Code Reviews| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 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 GdkColor color = {0}; | |
|
Evan Stade
2015/03/16 23:39:27
use GDK_COLOR_RGB here and elsewhere.
GdkC
dschuyler
2015/03/17 01:19:28
Done.
| |
| 384 color.green = ~0; | |
| 385 GtkStyle* entry_style = GetEntryStyle(); | |
| 386 return GetReadableColor(color, entry_style->base[GTK_STATE_NORMAL]); | |
| 387 } | |
| 388 case kColorId_ResultsTablePositiveHoveredText: { | |
| 389 GdkColor color = {0}; | |
| 390 color.green = ~0; | |
| 391 GtkStyle* entry_style = GetEntryStyle(); | |
| 392 return GetReadableColor(color, entry_style->base[GTK_STATE_PRELIGHT]); | |
| 393 } | |
| 394 case kColorId_ResultsTablePositiveSelectedText: { | |
| 395 GdkColor color = {0}; | |
| 396 color.green = ~0; | |
| 397 GtkStyle* entry_style = GetEntryStyle(); | |
| 398 return GetReadableColor(color, entry_style->base[GTK_STATE_SELECTED]); | |
| 399 } | |
| 400 case kColorId_ResultsTableNegativeText: { | |
| 401 GdkColor color = {0}; | |
| 402 color.red = ~0; | |
| 403 color = color; | |
| 404 GtkStyle* entry_style = GetEntryStyle(); | |
| 405 return GetReadableColor(color, entry_style->base[GTK_STATE_NORMAL]); | |
| 406 } | |
| 407 case kColorId_ResultsTableNegativeHoveredText: { | |
| 408 GdkColor color = {0}; | |
| 409 color.red = ~0; | |
| 410 GtkStyle* entry_style = GetEntryStyle(); | |
| 411 return GetReadableColor(color, entry_style->base[GTK_STATE_PRELIGHT]); | |
| 412 } | |
| 413 case kColorId_ResultsTableNegativeSelectedText: { | |
| 414 GdkColor color = {0}; | |
| 415 color.red = ~0; | |
| 416 GtkStyle* entry_style = GetEntryStyle(); | |
| 417 return GetReadableColor(color, entry_style->base[GTK_STATE_SELECTED]); | |
| 418 } | |
| 376 case kColorId_NumColors: | 419 case kColorId_NumColors: |
| 377 NOTREACHED(); | 420 NOTREACHED(); |
| 378 break; | 421 break; |
| 379 } | 422 } |
| 380 | 423 |
| 381 return SkColorToGdkColor(kInvalidColorIdColor); | 424 return SkColorToGdkColor(kInvalidColorIdColor); |
| 382 } | 425 } |
| 383 | 426 |
| 384 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { | 427 GtkWidget* NativeThemeGtk2::GetRealizedWindow() const { |
| 385 if (!fake_window_) { | 428 if (!fake_window_) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 0, 0, | 529 0, 0, |
| 487 rect.width(), rect.height()); | 530 rect.width(), rect.height()); |
| 488 SkBitmap arrow = GdkPixbufToImageSkia(pb); | 531 SkBitmap arrow = GdkPixbufToImageSkia(pb); |
| 489 canvas->drawBitmap(arrow, rect.x(), rect.y()); | 532 canvas->drawBitmap(arrow, rect.x(), rect.y()); |
| 490 | 533 |
| 491 g_object_unref(pb); | 534 g_object_unref(pb); |
| 492 g_object_unref(pm); | 535 g_object_unref(pm); |
| 493 } | 536 } |
| 494 | 537 |
| 495 } // namespace libgtk2ui | 538 } // namespace libgtk2ui |
| OLD | NEW |