diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 18:47:55 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-26 18:47:55 +0000 |
commit | b1550d56de4c8e7ddde315c605ce1f14f7b7b436 (patch) | |
tree | 4f476626722c29acfe8829549c8511e82bcae69f | |
parent | 2bbdb0e45ae3a8f1341d19f7a07f17355cf28ba0 (diff) | |
download | chromium_src-b1550d56de4c8e7ddde315c605ce1f14f7b7b436.zip chromium_src-b1550d56de4c8e7ddde315c605ce1f14f7b7b436.tar.gz chromium_src-b1550d56de4c8e7ddde315c605ce1f14f7b7b436.tar.bz2 |
GTK: fix hover state of chrome buttons in some border cases.
Most notably, with Chrome theme mode, the browser actions toolbar buttons will not stay hovered after showing/hiding the context menu for them.
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/1338005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42791 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/browser_actions_toolbar_gtk.cc | 13 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_chrome_button.h | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/hover_controller_gtk.cc | 6 |
4 files changed, 18 insertions, 6 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc index 954b5f9..d177fab 100644 --- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc @@ -17,6 +17,7 @@ #include "chrome/browser/gtk/gtk_chrome_shrinkable_hbox.h" #include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/gtk_util.h" +#include "chrome/browser/gtk/hover_controller_gtk.h" #include "chrome/browser/gtk/menu_gtk.h" #include "chrome/browser/gtk/view_id_util.h" #include "chrome/browser/profile.h" @@ -67,7 +68,8 @@ gint WidthForIconCount(gint icon_count) { class BrowserActionButton : public NotificationObserver, public ImageLoadingTracker::Observer, - public ExtensionContextMenuModel::PopupDelegate { + public ExtensionContextMenuModel::PopupDelegate, + public MenuGtk::Delegate { public: BrowserActionButton(BrowserActionsToolbarGtk* toolbar, Extension* extension) @@ -177,6 +179,11 @@ class BrowserActionButton : public NotificationObserver, } private: + // MenuGtk::Delegate implementation. + virtual void StoppedShowing() { + gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_.get())); + } + // Returns true to prevent further processing of the event that caused us to // show the popup, or false to continue processing. bool ShowPopup(bool devtools) { @@ -222,7 +229,9 @@ class BrowserActionButton : public NotificationObserver, action->toolbar_->browser(), action)); action->context_menu_.reset( - new MenuGtk(NULL, action->context_menu_model_.get())); + new MenuGtk(action, action->context_menu_model_.get())); + gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(action->button_.get()), + GTK_STATE_PRELIGHT); action->context_menu_->Popup(widget, event); return TRUE; diff --git a/chrome/browser/gtk/gtk_chrome_button.cc b/chrome/browser/gtk/gtk_chrome_button.cc index f2b94e4..a8bd49d 100644 --- a/chrome/browser/gtk/gtk_chrome_button.cc +++ b/chrome/browser/gtk/gtk_chrome_button.cc @@ -106,7 +106,8 @@ static gboolean gtk_chrome_button_expose(GtkWidget* widget, } else { double effective_hover_state = paint_state == GTK_STATE_PRELIGHT ? 1.0 : 0.0; - if (priv->hover_state >= 0.0) + // |paint_state| overrides |hover_state|. + if (priv->hover_state >= 0.0 && priv->paint_state < 0) effective_hover_state = priv->hover_state; if (paint_state == GTK_STATE_ACTIVE) { diff --git a/chrome/browser/gtk/gtk_chrome_button.h b/chrome/browser/gtk/gtk_chrome_button.h index 56ef67c..762f238 100644 --- a/chrome/browser/gtk/gtk_chrome_button.h +++ b/chrome/browser/gtk/gtk_chrome_button.h @@ -51,7 +51,7 @@ void gtk_chrome_button_set_use_gtk_rendering(GtkChromeButton* button, // Sets the partial hover state of the button. The acceptable range is 0.0 to // 1.0. If |state| is outside of that range, then revert the button to normal -// hovering. +// hovering. This can be overridden by gtk_chrome_button_set_paint_state. void gtk_chrome_button_set_hover_state(GtkChromeButton* button, gdouble state); diff --git a/chrome/browser/gtk/hover_controller_gtk.cc b/chrome/browser/gtk/hover_controller_gtk.cc index 0be9da9..50a8f1a 100644 --- a/chrome/browser/gtk/hover_controller_gtk.cc +++ b/chrome/browser/gtk/hover_controller_gtk.cc @@ -101,10 +101,12 @@ gboolean HoverControllerGtk::OnEnter(GtkWidget* widget, gboolean HoverControllerGtk::OnLeave(GtkWidget* widget, GdkEventCrossing* event) { // When the user is holding a mouse button, we don't want to animate. - if (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) + if (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) { hover_animation_.Reset(); - else + gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0); + } else { hover_animation_.Hide(); + } return FALSE; } |