diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:41:53 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 19:41:53 +0000 |
commit | af62bb4afd0dba5e607643f818a08a2aec642a80 (patch) | |
tree | 577687d6570ae15b9d23ccf2673eb669a31c4866 /chrome/browser/gtk/custom_button.h | |
parent | b8da78ad0ca066ada021b02bf4aaf1a686ef5af3 (diff) | |
download | chromium_src-af62bb4afd0dba5e607643f818a08a2aec642a80.zip chromium_src-af62bb4afd0dba5e607643f818a08a2aec642a80.tar.gz chromium_src-af62bb4afd0dba5e607643f818a08a2aec642a80.tar.bz2 |
Revert "Revert "Add button tinting to the toolbar buttons.""
This reverts commit r20399 and re-applies the button tinting
code. There's a fix for the go button gtk unittest by checking
to see if the browser is non-NULL before getting the theme provider.
TBR=erg
Review URL: http://codereview.chromium.org/155369
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/custom_button.h')
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index 143a090..2c6bc68 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -11,20 +11,28 @@ #include "base/gfx/rect.h" #include "base/scoped_ptr.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "chrome/common/owned_widget_gtk.h" +class ThemeProvider; + // These classes implement two kinds of custom-drawn buttons. They're // used on the toolbar and the bookmarks bar. // CustomDrawButtonBase provides the base for building a custom drawn button. // It handles managing the pixbufs containing all the static images used to draw // the button. It also manages painting these pixbufs. -class CustomDrawButtonBase { +class CustomDrawButtonBase : public NotificationObserver { public: - CustomDrawButtonBase(int normal_id, + // If the images come from ResourceBundle rather than the theme provider, + // pass in NULL for |theme_provider|. + CustomDrawButtonBase(ThemeProvider* theme_provider, + int normal_id, int active_id, int highlight_id, int depressed_id); + ~CustomDrawButtonBase(); GdkPixbuf* pixbufs(int i) const { return pixbufs_[i]; } @@ -33,6 +41,11 @@ class CustomDrawButtonBase { void set_paint_override(int state) { paint_override_ = state; } + // Provide NotificationObserver implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + private: // We store one GdkPixbuf* for each possible state of the button; // INSENSITIVE is the last available state; @@ -41,6 +54,17 @@ class CustomDrawButtonBase { // If non-negative, the state to paint the button. int paint_override_; + // We need to remember the image ids that the user passes in and the theme + // provider so we can reload images if the user changes theme. + int normal_id_; + int active_id_; + int highlight_id_; + int depressed_id_; + ThemeProvider* theme_provider_; + + // Used to listen for theme change notifications. + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase); }; @@ -56,9 +80,19 @@ class CustomDrawButton { int highlight_id, int depressed_id, const char* stock_id); - explicit CustomDrawButton(const std::string& filename); + + // Same as above, but uses themed (and possibly tinted) images. + CustomDrawButton(ThemeProvider* theme_provider, + int normal_id, + int active_id, + int highlight_id, + int depressed_id, + const char* stock_id); + ~CustomDrawButton(); + void Init(); + GtkWidget* widget() const { return widget_.get(); } gfx::Rect bounds() const { |