From 6463cb2a117dcd866a12becb513cfdba935c16e5 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Tue, 26 May 2009 20:18:21 +0000 Subject: Refactor back/forward buttons to their own class. Fix them so the menu pops up on drags and the buttons look depressed when the menu is showing. BUG=12427 TEST=back/forward button behavior should be as on windows (see bug desc. for details). Review URL: http://codereview.chromium.org/113806 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16898 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/gtk/custom_button.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'chrome/browser/gtk/custom_button.cc') diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index ed1f0b3..e438016 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -14,7 +14,8 @@ CustomDrawButtonBase::CustomDrawButtonBase( int normal_id, int active_id, int highlight_id, - int depressed_id) { + int depressed_id) + : paint_override_(-1) { // Load the button images from the resource bundle. ResourceBundle& rb = ResourceBundle::GetSharedInstance(); pixbufs_[GTK_STATE_NORMAL] = normal_id ? rb.GetPixbufNamed(normal_id) : NULL; @@ -30,11 +31,12 @@ CustomDrawButtonBase::~CustomDrawButtonBase() { } gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) { - GdkPixbuf* pixbuf = pixbufs(GTK_WIDGET_STATE(widget)); + GdkPixbuf* pixbuf = pixbufs_[paint_override_ >= 0 ? + paint_override_ : GTK_WIDGET_STATE(widget)]; // Fall back to the default image if we don't have one for this state. if (!pixbuf) - pixbuf = pixbufs(GTK_STATE_NORMAL); + pixbuf = pixbufs_[GTK_STATE_NORMAL]; if (!pixbuf) return FALSE; @@ -73,6 +75,16 @@ CustomDrawButton::~CustomDrawButton() { widget_.Destroy(); } +void CustomDrawButton::SetPaintOverride(GtkStateType state) { + button_base_.set_paint_override(state); + gtk_widget_queue_draw(widget_.get()); +} + +void CustomDrawButton::UnsetPaintOverride() { + button_base_.set_paint_override(-1); + gtk_widget_queue_draw(widget_.get()); +} + // static gboolean CustomDrawButton::OnExpose(GtkWidget* widget, GdkEventExpose* e, -- cgit v1.1