diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 22:56:30 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-11 22:56:30 +0000 |
commit | 4efb56d87a1927f4e497257805b54ad3bda87bec (patch) | |
tree | d9d565e8b908f576066fb47ec5bf081afd093422 | |
parent | f8d172cbaeb8cd49be95b5581473805989e89ca6 (diff) | |
download | chromium_src-4efb56d87a1927f4e497257805b54ad3bda87bec.zip chromium_src-4efb56d87a1927f4e497257805b54ad3bda87bec.tar.gz chromium_src-4efb56d87a1927f4e497257805b54ad3bda87bec.tar.bz2 |
GTK: Use themed background images in toolbar buttons.
When a chrome theme asks to use a background image on a toolbar button,
use it. Oddly enough, all of the graphics drawing was written but the
plumbing of actually setting the background wasn't...
TEST=Good Smile, Chuck Anderson, etc. should have button backgrounds which
are very different from the toolbar background in the GTK port.
BUG=NONE
Review URL: http://codereview.chromium.org/384057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31728 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/back_forward_button_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.cc | 23 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/go_button_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/toolbar_star_toggle_gtk.cc | 6 |
8 files changed, 42 insertions, 18 deletions
diff --git a/chrome/browser/gtk/back_forward_button_gtk.cc b/chrome/browser/gtk/back_forward_button_gtk.cc index e5f6125..f17576d 100644 --- a/chrome/browser/gtk/back_forward_button_gtk.cc +++ b/chrome/browser/gtk/back_forward_button_gtk.cc @@ -25,13 +25,14 @@ BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) : browser_(browser), is_forward_(is_forward), show_menu_factory_(this) { - int normal, active, highlight, depressed, tooltip; + int normal, active, highlight, depressed, background, tooltip; const char* stock; if (is_forward) { normal = IDR_FORWARD; active = IDR_FORWARD_P; highlight = IDR_FORWARD_H; depressed = IDR_FORWARD_D; + background = IDR_FORWARD_MASK; tooltip = IDS_TOOLTIP_FORWARD; stock = GTK_STOCK_GO_FORWARD; } else { @@ -39,12 +40,13 @@ BackForwardButtonGtk::BackForwardButtonGtk(Browser* browser, bool is_forward) active = IDR_BACK_P; highlight = IDR_BACK_H; depressed = IDR_BACK_D; + background = IDR_BACK_MASK; tooltip = IDS_TOOLTIP_BACK; stock = GTK_STOCK_GO_BACK; } button_.reset(new CustomDrawButton( GtkThemeProvider::GetFrom(browser_->profile()), - normal, active, highlight, depressed, stock, + normal, active, highlight, depressed, background, stock, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_widget_set_tooltip_text(widget(), l10n_util::GetStringUTF8(tooltip).c_str()); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index f9ab807..a0e21ab 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -164,10 +164,12 @@ void BrowserToolbarGtk::Init(Profile* profile, gtk_box_pack_start(GTK_BOX(toolbar_), back_forward_hbox_, FALSE, FALSE, 0); reload_.reset(BuildToolbarButton(IDR_RELOAD, IDR_RELOAD_P, IDR_RELOAD_H, 0, - l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD), - GTK_STOCK_REFRESH)); + IDR_BUTTON_MASK, + l10n_util::GetStringUTF8(IDS_TOOLTIP_RELOAD), + GTK_STOCK_REFRESH)); home_.reset(BuildToolbarButton(IDR_HOME, IDR_HOME_P, IDR_HOME_H, 0, + IDR_BUTTON_MASK, l10n_util::GetStringUTF8(IDS_TOOLTIP_HOME), GTK_STOCK_HOME)); gtk_util::SetButtonTriggersNavigation(home_->widget()); @@ -453,10 +455,11 @@ gfx::Rect BrowserToolbarGtk::GetLocationStackBounds() const { CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( int normal_id, int active_id, int highlight_id, int depressed_id, - const std::string& localized_tooltip, const char* stock_id) { + int background_id, const std::string& localized_tooltip, + const char* stock_id) { CustomDrawButton* button = new CustomDrawButton( GtkThemeProvider::GetFrom(profile_), - normal_id, active_id, highlight_id, depressed_id, stock_id, + normal_id, active_id, highlight_id, depressed_id, background_id, stock_id, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_set_tooltip_text(button->widget(), diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h index cf726b1..dd5aea9e 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.h +++ b/chrome/browser/gtk/browser_toolbar_gtk.h @@ -108,6 +108,7 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver, int active_id, int highlight_id, int depressed_id, + int background_id, const std::string& localized_tooltip, const char* stock_id); diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index e21e62d..413ccd7 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -18,13 +18,15 @@ #include "grit/theme_resources.h" CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, - int normal_id, int active_id, int highlight_id, int depressed_id) + int normal_id, int active_id, int highlight_id, int depressed_id, + int background_id) : background_image_(NULL), paint_override_(-1), normal_id_(normal_id), active_id_(active_id), highlight_id_(highlight_id), depressed_id_(depressed_id), + button_background_id_(background_id), theme_provider_(theme_provider) { for (int i = 0; i < (GTK_STATE_INSENSITIVE + 1); ++i) surfaces_[i].reset(new CairoCachedSurface); @@ -127,11 +129,22 @@ void CustomDrawButtonBase::Observe(NotificationType type, surfaces_[GTK_STATE_SELECTED]->UsePixbuf(NULL); surfaces_[GTK_STATE_INSENSITIVE]->UsePixbuf(depressed_id_ ? theme_provider_->GetRTLEnabledPixbufNamed(depressed_id_) : NULL); + + // Use the tinted background in some themes. + if (button_background_id_) { + SkColor color = theme_provider_->GetColor( + BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); + SkBitmap* background = theme_provider_->GetBitmapNamed( + IDR_THEME_BUTTON_BACKGROUND); + SkBitmap* mask = theme_provider_->GetBitmapNamed(button_background_id_); + + SetBackground(color, background, mask); + } } CustomDrawButton::CustomDrawButton(int normal_id, int active_id, int highlight_id, int depressed_id) - : button_base_(NULL, normal_id, active_id, highlight_id, depressed_id), + : button_base_(NULL, normal_id, active_id, highlight_id, depressed_id, 0), theme_provider_(NULL), gtk_stock_name_(NULL), icon_size_(GTK_ICON_SIZE_INVALID) { @@ -143,9 +156,9 @@ CustomDrawButton::CustomDrawButton(int normal_id, int active_id, CustomDrawButton::CustomDrawButton(GtkThemeProvider* theme_provider, int normal_id, int active_id, int highlight_id, int depressed_id, - const char* stock_id, GtkIconSize stock_size) + int background_id, const char* stock_id, GtkIconSize stock_size) : button_base_(theme_provider, normal_id, active_id, highlight_id, - depressed_id), + depressed_id, background_id), theme_provider_(theme_provider), gtk_stock_name_(stock_id), icon_size_(stock_size) { @@ -208,7 +221,7 @@ CustomDrawButton* CustomDrawButton::CloseButton( GtkThemeProvider* theme_provider) { CustomDrawButton* button = new CustomDrawButton( theme_provider, IDR_CLOSE_BAR, IDR_CLOSE_BAR_P, - IDR_CLOSE_BAR_H, 0, GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + IDR_CLOSE_BAR_H, 0, 0, GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); return button; } diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index 27dc275..250f8ec 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -33,7 +33,8 @@ class CustomDrawButtonBase : public NotificationObserver { int normal_id, int active_id, int highlight_id, - int depressed_id); + int depressed_id, + int background_id); ~CustomDrawButtonBase(); @@ -71,6 +72,7 @@ class CustomDrawButtonBase : public NotificationObserver { int active_id_; int highlight_id_; int depressed_id_; + int button_background_id_; GtkThemeProvider* theme_provider_; // Used to listen for theme change notifications. @@ -97,6 +99,7 @@ class CustomDrawButton : public NotificationObserver { int active_id, int highlight_id, int depressed_id, + int background_id, const char* stock_id, GtkIconSize stock_size); diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 9c02afb..f736798 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -225,7 +225,7 @@ void FindBarGtk::InitWidgets() { find_next_button_.reset(new CustomDrawButton(theme_provider_, IDR_FINDINPAGE_NEXT, IDR_FINDINPAGE_NEXT_H, IDR_FINDINPAGE_NEXT_H, - IDR_FINDINPAGE_NEXT_P, GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU)); + IDR_FINDINPAGE_NEXT_P, 0, GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU)); g_signal_connect(G_OBJECT(find_next_button_->widget()), "clicked", G_CALLBACK(OnClicked), this); gtk_widget_set_tooltip_text(find_next_button_->widget(), @@ -235,7 +235,7 @@ void FindBarGtk::InitWidgets() { find_previous_button_.reset(new CustomDrawButton(theme_provider_, IDR_FINDINPAGE_PREV, IDR_FINDINPAGE_PREV_H, IDR_FINDINPAGE_PREV_H, - IDR_FINDINPAGE_PREV_P, GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU)); + IDR_FINDINPAGE_PREV_P, 0, GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU)); g_signal_connect(G_OBJECT(find_previous_button_->widget()), "clicked", G_CALLBACK(OnClicked), this); gtk_widget_set_tooltip_text(find_previous_button_->widget(), diff --git a/chrome/browser/gtk/go_button_gtk.cc b/chrome/browser/gtk/go_button_gtk.cc index bd3bc23..03bc77f 100644 --- a/chrome/browser/gtk/go_button_gtk.cc +++ b/chrome/browser/gtk/go_button_gtk.cc @@ -33,8 +33,8 @@ GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser) state_(BS_NORMAL), theme_provider_(browser ? GtkThemeProvider::GetFrom(browser->profile()) : NULL), - go_(theme_provider_, IDR_GO, IDR_GO_P, IDR_GO_H, 0), - stop_(theme_provider_, IDR_STOP, IDR_STOP_P, IDR_STOP_H, 0), + go_(theme_provider_, IDR_GO, IDR_GO_P, IDR_GO_H, 0, IDR_GO_MASK), + stop_(theme_provider_, IDR_STOP, IDR_STOP_P, IDR_STOP_H, 0, IDR_GO_MASK), widget_(gtk_chrome_button_new()) { gtk_widget_set_size_request(widget_.get(), go_.Width(), go_.Height()); diff --git a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc index c6ba974..328b5e7 100644 --- a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc +++ b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc @@ -23,8 +23,10 @@ ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host) widget_(gtk_chrome_button_new()), is_starred_(false), theme_provider_(GtkThemeProvider::GetFrom(host->profile())), - unstarred_(theme_provider_, IDR_STAR, IDR_STAR_P, IDR_STAR_H, IDR_STAR_D), - starred_(theme_provider_, IDR_STARRED, IDR_STARRED_P, IDR_STARRED_H, 0) { + unstarred_(theme_provider_, IDR_STAR, IDR_STAR_P, IDR_STAR_H, IDR_STAR_D, + IDR_STAR_MASK), + starred_(theme_provider_, IDR_STARRED, IDR_STARRED_P, IDR_STARRED_H, 0, + IDR_STAR_MASK) { gtk_widget_set_size_request(widget_.get(), unstarred_.Width(), unstarred_.Height()); |