OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/gtk_theme_provider.h" | 5 #include "chrome/browser/gtk/gtk_theme_provider.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/gfx/color_utils.h" | 9 #include "app/gfx/color_utils.h" |
10 #include "app/gfx/gtk_util.h" | 10 #include "app/gfx/gtk_util.h" |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // The inactive color/tint is special: We *must* use the exact insensitive | 545 // The inactive color/tint is special: We *must* use the exact insensitive |
546 // color for all inactive windows, otherwise we end up neon pink half the | 546 // color for all inactive windows, otherwise we end up neon pink half the |
547 // time. | 547 // time. |
548 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_FRAME_INACTIVE, | 548 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_FRAME_INACTIVE, |
549 &inactive_frame_color); | 549 &inactive_frame_color); |
550 SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INACTIVE, | 550 SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INACTIVE, |
551 &inactive_frame_color); | 551 &inactive_frame_color); |
552 SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE, | 552 SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE, |
553 &inactive_frame_color); | 553 &inactive_frame_color); |
554 | 554 |
555 focus_ring_color_ = GdkToSkColor(&button_color); | |
556 GdkColor thumb_active_color, thumb_inactive_color, track_color; | |
557 GtkThemeProvider::GetScrollbarColors(&thumb_active_color, | |
558 &thumb_inactive_color, | |
559 &track_color); | |
560 thumb_active_color_ = GdkToSkColor(&thumb_active_color); | |
561 thumb_inactive_color_ = GdkToSkColor(&thumb_inactive_color); | |
562 track_color_ = GdkToSkColor(&track_color); | |
563 | |
564 // We pick the text and background colors for the NTP out of the colors for a | 555 // We pick the text and background colors for the NTP out of the colors for a |
565 // GtkEntry. We do this because GtkEntries background color is never the same | 556 // GtkEntry. We do this because GtkEntries background color is never the same |
566 // as |toolbar_color|, is usually a white, and when it isn't a white, | 557 // as |toolbar_color|, is usually a white, and when it isn't a white, |
567 // provides sufficient contrast to |toolbar_color|. Try this out with | 558 // provides sufficient contrast to |toolbar_color|. Try this out with |
568 // Darklooks, HighContrastInverse or ThinIce. | 559 // Darklooks, HighContrastInverse or ThinIce. |
569 GtkStyle* entry_style = gtk_rc_get_style(fake_entry_.get()); | 560 GtkStyle* entry_style = gtk_rc_get_style(fake_entry_.get()); |
570 GdkColor ntp_background = entry_style->base[GTK_STATE_NORMAL]; | 561 GdkColor ntp_background = entry_style->base[GTK_STATE_NORMAL]; |
571 GdkColor ntp_foreground = entry_style->fg[GTK_STATE_NORMAL]; | 562 GdkColor ntp_foreground = entry_style->fg[GTK_STATE_NORMAL]; |
572 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_BACKGROUND, | 563 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_BACKGROUND, |
573 &ntp_background); | 564 &ntp_background); |
(...skipping 20 matching lines...) Expand all Loading... |
594 link_color = &kDefaultLinkColor; | 585 link_color = &kDefaultLinkColor; |
595 | 586 |
596 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK, | 587 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK, |
597 link_color); | 588 link_color); |
598 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE, | 589 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_LINK_UNDERLINE, |
599 link_color); | 590 link_color); |
600 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK, | 591 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK, |
601 link_color); | 592 link_color); |
602 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE, | 593 SetThemeColorFromGtk(BrowserThemeProvider::COLOR_NTP_SECTION_LINK_UNDERLINE, |
603 link_color); | 594 link_color); |
| 595 |
| 596 // Generate the colors that we pass to WebKit. |
| 597 focus_ring_color_ = GdkToSkColor(&button_color); |
| 598 GdkColor thumb_active_color, thumb_inactive_color, track_color; |
| 599 GtkThemeProvider::GetScrollbarColors(&thumb_active_color, |
| 600 &thumb_inactive_color, |
| 601 &track_color); |
| 602 thumb_active_color_ = GdkToSkColor(&thumb_active_color); |
| 603 thumb_inactive_color_ = GdkToSkColor(&thumb_inactive_color); |
| 604 track_color_ = GdkToSkColor(&track_color); |
| 605 |
| 606 // Some GTK themes only define the text selection colors on the GtkEntry |
| 607 // class, so we need to use that for getting selection colors. |
| 608 active_selection_bg_color_ = |
| 609 GdkToSkColor(&entry_style->base[GTK_STATE_SELECTED]); |
| 610 active_selection_fg_color_ = |
| 611 GdkToSkColor(&entry_style->text[GTK_STATE_SELECTED]); |
| 612 inactive_selection_bg_color_ = |
| 613 GdkToSkColor(&entry_style->base[GTK_STATE_ACTIVE]); |
| 614 inactive_selection_fg_color_ = |
| 615 GdkToSkColor(&entry_style->text[GTK_STATE_ACTIVE]); |
604 } | 616 } |
605 | 617 |
606 void GtkThemeProvider::LoadDefaultValues() { | 618 void GtkThemeProvider::LoadDefaultValues() { |
607 focus_ring_color_ = SkColorSetARGB(255, 229, 151, 0); | 619 focus_ring_color_ = SkColorSetARGB(255, 229, 151, 0); |
608 thumb_active_color_ = SkColorSetRGB(250, 248, 245); | 620 thumb_active_color_ = SkColorSetRGB(250, 248, 245); |
609 thumb_inactive_color_ = SkColorSetRGB(240, 235, 229); | 621 thumb_inactive_color_ = SkColorSetRGB(240, 235, 229); |
610 track_color_ = SkColorSetRGB(227, 221, 216); | 622 track_color_ = SkColorSetRGB(227, 221, 216); |
| 623 |
| 624 active_selection_bg_color_ = SkColorSetRGB(30, 144, 255); |
| 625 active_selection_fg_color_ = SK_ColorBLACK; |
| 626 inactive_selection_bg_color_ = SkColorSetRGB(200, 200, 200); |
| 627 inactive_selection_fg_color_ = SkColorSetRGB(50, 50, 50); |
611 } | 628 } |
612 | 629 |
613 void GtkThemeProvider::SetThemeColorFromGtk(int id, const GdkColor* color) { | 630 void GtkThemeProvider::SetThemeColorFromGtk(int id, const GdkColor* color) { |
614 colors_[id] = GdkToSkColor(color); | 631 colors_[id] = GdkToSkColor(color); |
615 } | 632 } |
616 | 633 |
617 void GtkThemeProvider::SetThemeTintFromGtk(int id, const GdkColor* color) { | 634 void GtkThemeProvider::SetThemeTintFromGtk(int id, const GdkColor* color) { |
618 color_utils::HSL default_tint = GetDefaultTint(id); | 635 color_utils::HSL default_tint = GetDefaultTint(id); |
619 color_utils::HSL hsl; | 636 color_utils::HSL hsl; |
620 color_utils::SkColorToHSL(GdkToSkColor(color), &hsl); | 637 color_utils::SkColorToHSL(GdkToSkColor(color), &hsl); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 724 } |
708 | 725 |
709 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, | 726 void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button, |
710 GtkThemeProvider* provider) { | 727 GtkThemeProvider* provider) { |
711 std::vector<GtkWidget*>::iterator it = | 728 std::vector<GtkWidget*>::iterator it = |
712 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), | 729 find(provider->chrome_buttons_.begin(), provider->chrome_buttons_.end(), |
713 button); | 730 button); |
714 if (it != provider->chrome_buttons_.end()) | 731 if (it != provider->chrome_buttons_.end()) |
715 provider->chrome_buttons_.erase(it); | 732 provider->chrome_buttons_.erase(it); |
716 } | 733 } |
OLD | NEW |