diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 21:49:43 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 21:49:43 +0000 |
commit | 148e47de6904b89adf7239e1f3bdb831cddcbf4c (patch) | |
tree | 090953777e1818ea61295a38cc9498c8ddb9114f /chrome | |
parent | b6eb23025f4e3db115522faa1f26a71e606e54eb (diff) | |
download | chromium_src-148e47de6904b89adf7239e1f3bdb831cddcbf4c.zip chromium_src-148e47de6904b89adf7239e1f3bdb831cddcbf4c.tar.gz chromium_src-148e47de6904b89adf7239e1f3bdb831cddcbf4c.tar.bz2 |
GTK: Tint omnibox icons in GTK mode differently.
- Tint highlighted icons (the *_DARK variety) the color of highlighted text.
- Use new variants of the IDR_OMNIBOX_HTTP* and IDR_OMNIBOX_HISTORY* icons in
GTK mode where there isn't a white background.
BUG=41189
TEST=none
Review URL: http://codereview.chromium.org/1559029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/theme/omnibox_history_dark_transparent.png | bin | 0 -> 311 bytes | |||
-rw-r--r-- | chrome/app/theme/omnibox_history_transparent.png | bin | 0 -> 317 bytes | |||
-rw-r--r-- | chrome/app/theme/omnibox_http_dark_transparent.png | bin | 0 -> 422 bytes | |||
-rw-r--r-- | chrome/app/theme/omnibox_http_transparent.png | bin | 0 -> 423 bytes | |||
-rw-r--r-- | chrome/app/theme/theme_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.cc | 58 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_theme_provider.h | 7 |
7 files changed, 64 insertions, 5 deletions
diff --git a/chrome/app/theme/omnibox_history_dark_transparent.png b/chrome/app/theme/omnibox_history_dark_transparent.png Binary files differnew file mode 100644 index 0000000..2edc8d8 --- /dev/null +++ b/chrome/app/theme/omnibox_history_dark_transparent.png diff --git a/chrome/app/theme/omnibox_history_transparent.png b/chrome/app/theme/omnibox_history_transparent.png Binary files differnew file mode 100644 index 0000000..4b0fc77 --- /dev/null +++ b/chrome/app/theme/omnibox_history_transparent.png diff --git a/chrome/app/theme/omnibox_http_dark_transparent.png b/chrome/app/theme/omnibox_http_dark_transparent.png Binary files differnew file mode 100644 index 0000000..4f6fa89 --- /dev/null +++ b/chrome/app/theme/omnibox_http_dark_transparent.png diff --git a/chrome/app/theme/omnibox_http_transparent.png b/chrome/app/theme/omnibox_http_transparent.png Binary files differnew file mode 100644 index 0000000..e432be1 --- /dev/null +++ b/chrome/app/theme/omnibox_http_transparent.png diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index c38c3b2..baa714b 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -46,9 +46,13 @@ <include name="IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R" file="location_bar_keyword_search_r.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HISTORY" file="omnibox_history.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HISTORY_DARK" file="omnibox_history_dark.png" type="BINDATA" /> + <include name="IDR_OMNIBOX_HISTORY_TRANSPARENT" file="omnibox_history_transparent.png" type="BINDATA" /> + <include name="IDR_OMNIBOX_HISTORY_DARK_TRANSPARENT" file="omnibox_history_dark_transparent.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HISTORY_SELECTED" file="omnibox_history_selected.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HTTP" file="omnibox_http.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HTTP_DARK" file="omnibox_http_dark.png" type="BINDATA" /> + <include name="IDR_OMNIBOX_HTTP_TRANSPARENT" file="omnibox_http_transparent.png" type="BINDATA" /> + <include name="IDR_OMNIBOX_HTTP_DARK_TRANSPARENT" file="omnibox_http_dark_transparent.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HTTP_SELECTED" file="omnibox_http_selected.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HTTPS_GREEN" file="omnibox_https_green.png" type="BINDATA" /> <include name="IDR_OMNIBOX_HTTPS_INVALID" file="omnibox_https_invalid.png" type="BINDATA" /> diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index dc9e0f5..b653c52 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -755,15 +755,49 @@ SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const { return GenerateFrameImage( BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE); } + // Two sets of omnibox icons, the one for normal http and the one for + // history, include white backgrounds (and are supposed to, for the windows + // chrome-theme). On linux, where we have all sorts of wacky themes and + // color combinations we need to deal with, switch them out with + // transparent background versions. + case IDR_OMNIBOX_HTTP: { + TintMap::const_iterator it = tints_.find( + BrowserThemeProvider::TINT_BUTTONS); + DCHECK(it != tints_.end()); + return GenerateTintedIcon(IDR_OMNIBOX_HTTP_TRANSPARENT, it->second); + } + case IDR_OMNIBOX_HISTORY: { + TintMap::const_iterator it = tints_.find( + BrowserThemeProvider::TINT_BUTTONS); + DCHECK(it != tints_.end()); + return GenerateTintedIcon(IDR_OMNIBOX_HISTORY_TRANSPARENT, it->second); + } + // In GTK mode, the dark versions of the omnibox icons only ever appear in + // the autocomplete popup and only against the current theme's GtkEntry + // base[GTK_STATE_SELECTED] color, so tint the icons so they won't collide + // with the selected color. + case IDR_OMNIBOX_HTTP_DARK: { + color_utils::HSL tint; + GetEntryForegroundHSL(&tint); + return GenerateTintedIcon(IDR_OMNIBOX_HTTP_DARK_TRANSPARENT, tint); + } + case IDR_OMNIBOX_HISTORY_DARK: { + color_utils::HSL tint; + GetEntryForegroundHSL(&tint); + return GenerateTintedIcon(IDR_OMNIBOX_HISTORY_DARK_TRANSPARENT, tint); + } + case IDR_OMNIBOX_SEARCH_DARK: + case IDR_OMNIBOX_MORE_DARK: + case IDR_OMNIBOX_STAR_DARK: { + color_utils::HSL tint; + GetEntryForegroundHSL(&tint); + return GenerateTintedIcon(id, tint); + } default: { - // This is a tinted button. Tint it and return it. - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - scoped_ptr<SkBitmap> button(new SkBitmap(*rb.GetBitmapNamed(id))); TintMap::const_iterator it = tints_.find( BrowserThemeProvider::TINT_BUTTONS); DCHECK(it != tints_.end()); - return new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap( - *button, it->second)); + return GenerateTintedIcon(id, it->second); } } } @@ -785,6 +819,20 @@ SkBitmap* GtkThemeProvider::GenerateTabImage(int base_id) const { bg_tint, 0, 0, bg_tint.width(), bg_tint.height())); } +SkBitmap* GtkThemeProvider::GenerateTintedIcon(int base_id, + color_utils::HSL tint) const { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + scoped_ptr<SkBitmap> button(new SkBitmap(*rb.GetBitmapNamed(base_id))); + return new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap( + *button, tint)); +} + +void GtkThemeProvider::GetEntryForegroundHSL(color_utils::HSL* tint) const { + GtkStyle* style = gtk_rc_get_style(fake_entry_.get()); + const GdkColor color = style->text[GTK_STATE_SELECTED]; + color_utils::SkColorToHSL(GdkToSkColor(&color), tint); +} + void GtkThemeProvider::OnDestroyChromeButton(GtkWidget* button) { std::vector<GtkWidget*>::iterator it = find(chrome_buttons_.begin(), chrome_buttons_.end(), button); diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 23c0a57..227bbbe 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -163,6 +163,13 @@ class GtkThemeProvider : public BrowserThemeProvider, // Takes the base frame image |base_id| and tints it with |tint_id|. SkBitmap* GenerateTabImage(int base_id) const; + // Tints an icon based on tint. + SkBitmap* GenerateTintedIcon(int base_id, color_utils::HSL tint) const; + + // Returns a tint that's the color of the current highlighted text in an + // entry. + void GetEntryForegroundHSL(color_utils::HSL* tint) const; + // A notification from the GtkChromeButton GObject destructor that we should // remove it from our internal list. CHROMEGTK_CALLBACK_0(GtkThemeProvider, void, OnDestroyChromeButton); |