diff options
-rw-r--r-- | chrome/browser/gtk/custom_button.cc | 125 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 39 | ||||
-rw-r--r-- | chrome/browser/gtk/go_button_gtk.cc | 40 | ||||
-rw-r--r-- | chrome/browser/gtk/go_button_gtk.h | 9 | ||||
-rw-r--r-- | chrome/browser/gtk/go_button_gtk_unittest.cc | 27 | ||||
-rw-r--r-- | chrome/browser/gtk/toolbar_star_toggle_gtk.cc | 16 | ||||
-rw-r--r-- | chrome/browser/gtk/toolbar_star_toggle_gtk.h | 5 |
7 files changed, 180 insertions, 81 deletions
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index 33a3a0e2..ea2607d 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -66,17 +66,25 @@ int CustomDrawButtonBase::Height() const { return surfaces_[0]->Height(); } -gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) { - CairoCachedSurface* pixbuf = - surfaces_[paint_override_ >= 0 ? - paint_override_ : GTK_WIDGET_STATE(widget)].get(); - - // Fall back to the default image if we don't have one for this state. - if (!pixbuf || !pixbuf->valid()) - pixbuf = surfaces_[GTK_STATE_NORMAL].get(); +gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, + GdkEventExpose* e, + gdouble hover_state) { + int paint_state = paint_override_ >= 0 ? + paint_override_ : GTK_WIDGET_STATE(widget); + + // If the paint state is PRELIGHT then set it to NORMAL (we will paint the + // hover state according to |hover_state_|). + if (paint_state == GTK_STATE_PRELIGHT) + paint_state = GTK_STATE_NORMAL; + bool animating_hover = hover_state > 0.0 && + paint_state == GTK_STATE_NORMAL; + CairoCachedSurface* pixbuf = PixbufForState(paint_state); + CairoCachedSurface* hover_pixbuf = PixbufForState(GTK_STATE_PRELIGHT); if (!pixbuf || !pixbuf->valid()) return FALSE; + if (animating_hover && (!hover_pixbuf || !hover_pixbuf->valid())) + return FALSE; cairo_t* cairo_context = gdk_cairo_create(GDK_DRAWABLE(widget->window)); cairo_translate(cairo_context, widget->allocation.x, widget->allocation.y); @@ -94,6 +102,12 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) { pixbuf->SetSource(cairo_context, x, y); cairo_paint(cairo_context); + + if (animating_hover) { + hover_pixbuf->SetSource(cairo_context, x, y); + cairo_paint_with_alpha(cairo_context, hover_state); + } + cairo_destroy(cairo_context); return TRUE; @@ -142,6 +156,70 @@ void CustomDrawButtonBase::Observe(NotificationType type, } } +CairoCachedSurface* CustomDrawButtonBase::PixbufForState(int state) { + CairoCachedSurface* pixbuf = surfaces_[state].get(); + + // Fall back to the default image if we don't have one for this state. + if (!pixbuf || !pixbuf->valid()) + pixbuf = surfaces_[GTK_STATE_NORMAL].get(); + + return pixbuf; +} + +// CustomDrawHoverController --------------------------------------------------- + +CustomDrawHoverController::CustomDrawHoverController(GtkWidget* widget) + : slide_animation_(this), + widget_(NULL) { + Init(widget); +} + +CustomDrawHoverController::CustomDrawHoverController() + : slide_animation_(this), + widget_(NULL) { +} + +CustomDrawHoverController::~CustomDrawHoverController() { +} + +void CustomDrawHoverController::Init(GtkWidget* widget) { + DCHECK(widget_ == NULL); + widget_ = widget; + g_signal_connect(widget_, "enter-notify-event", + G_CALLBACK(OnEnter), this); + g_signal_connect(widget_, "leave-notify-event", + G_CALLBACK(OnLeave), this); +} + +void CustomDrawHoverController::AnimationProgressed( + const Animation* animation) { + gtk_widget_queue_draw(widget_); +} + +// static +gboolean CustomDrawHoverController::OnEnter( + GtkWidget* widget, + GdkEventCrossing* event, + CustomDrawHoverController* controller) { + controller->slide_animation_.Show(); + return FALSE; +} + +// static +gboolean CustomDrawHoverController::OnLeave( + GtkWidget* widget, + GdkEventCrossing* event, + CustomDrawHoverController* controller) { + // When the user is holding a mouse button, we don't want to animste. + if (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) + controller->slide_animation_.Reset(); + else + controller->slide_animation_.Hide(); + return FALSE; +} + +// CustomDrawButton ------------------------------------------------------------ + 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, 0), @@ -176,9 +254,10 @@ CustomDrawButton::~CustomDrawButton() { void CustomDrawButton::Init() { widget_.Own(gtk_chrome_button_new()); - GTK_WIDGET_UNSET_FLAGS(widget_.get(), GTK_CAN_FOCUS); - g_signal_connect(widget_.get(), "expose-event", + GTK_WIDGET_UNSET_FLAGS(widget(), GTK_CAN_FOCUS); + g_signal_connect(widget(), "expose-event", G_CALLBACK(OnCustomExpose), this); + hover_controller_.Init(widget()); } void CustomDrawButton::Observe(NotificationType type, @@ -189,14 +268,14 @@ void CustomDrawButton::Observe(NotificationType type, void CustomDrawButton::SetPaintOverride(GtkStateType state) { button_base_.set_paint_override(state); - gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget_.get()), state); - gtk_widget_queue_draw(widget_.get()); + gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget()), state); + gtk_widget_queue_draw(widget()); } void CustomDrawButton::UnsetPaintOverride() { button_base_.set_paint_override(-1); - gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(widget_.get())); - gtk_widget_queue_draw(widget_.get()); + gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(widget())); + gtk_widget_queue_draw(widget()); } void CustomDrawButton::SetBackground(SkColor color, @@ -212,7 +291,8 @@ gboolean CustomDrawButton::OnCustomExpose(GtkWidget* widget, // Continue processing this expose event. return FALSE; } else { - return button->button_base_.OnExpose(widget, e); + double hover_state = button->hover_controller_.GetCurrentValue(); + return button->button_base_.OnExpose(widget, e, hover_state); } } @@ -230,20 +310,17 @@ void CustomDrawButton::SetBrowserTheme() { if (use_gtk && gtk_stock_name_) { gtk_button_set_image( - GTK_BUTTON(widget_.get()), + GTK_BUTTON(widget()), gtk_image_new_from_stock(gtk_stock_name_, icon_size_)); - gtk_widget_set_size_request(widget_.get(), -1, -1); - gtk_widget_set_app_paintable(widget_.get(), FALSE); - gtk_widget_set_double_buffered(widget_.get(), TRUE); + gtk_widget_set_size_request(widget(), -1, -1); + gtk_widget_set_app_paintable(widget(), FALSE); } else { - gtk_widget_set_size_request(widget_.get(), button_base_.Width(), + gtk_widget_set_size_request(widget(), button_base_.Width(), button_base_.Height()); - gtk_widget_set_app_paintable(widget_.get(), TRUE); - // We effectively double-buffer by virtue of having only one image... - gtk_widget_set_double_buffered(widget_.get(), FALSE); + gtk_widget_set_app_paintable(widget(), TRUE); } gtk_chrome_button_set_use_gtk_rendering( - GTK_CHROME_BUTTON(widget_.get()), use_gtk); + GTK_CHROME_BUTTON(widget()), use_gtk); } diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index 250f8ec..e7ab3d2 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -9,6 +9,7 @@ #include <string> +#include "app/slide_animation.h" #include "base/gfx/rect.h" #include "base/scoped_ptr.h" #include "chrome/common/notification_observer.h" @@ -42,7 +43,7 @@ class CustomDrawButtonBase : public NotificationObserver { int Width() const; int Height() const; - gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e); + gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, gdouble hover_state); void set_paint_override(int state) { paint_override_ = state; } int paint_override() const { return paint_override_; } @@ -56,6 +57,9 @@ class CustomDrawButtonBase : public NotificationObserver { const NotificationDetails& details); private: + // Get the CairoCachedSurface from |surfaces_| for |state|. + CairoCachedSurface* PixbufForState(int state); + // We store one surface for each possible state of the button; // INSENSITIVE is the last available state; scoped_ptr<CairoCachedSurface> surfaces_[GTK_STATE_INSENSITIVE + 1]; @@ -81,6 +85,35 @@ class CustomDrawButtonBase : public NotificationObserver { DISALLOW_COPY_AND_ASSIGN(CustomDrawButtonBase); }; +// CustomDrawHoverController is a convenience class that eases the common task +// of controlling the hover state of a button. The "hover state" refers to the +// percent opacity of a button's PRELIGHT. The PRELIGHT is animated such that +// when a user moves a mouse over a button the PRELIGHT fades in. +class CustomDrawHoverController : public AnimationDelegate { + public: + explicit CustomDrawHoverController(GtkWidget* widget); + CustomDrawHoverController(); + + virtual ~CustomDrawHoverController(); + + void Init(GtkWidget* widget); + + double GetCurrentValue() { + return slide_animation_.GetCurrentValue(); + } + + private: + virtual void AnimationProgressed(const Animation* animation); + + static gboolean OnEnter(GtkWidget* widget, GdkEventCrossing* event, + CustomDrawHoverController* controller); + static gboolean OnLeave(GtkWidget* widget, GdkEventCrossing* event, + CustomDrawHoverController* controller); + + SlideAnimation slide_animation_; + GtkWidget* widget_; +}; + // CustomDrawButton is a plain button where all its various states are drawn // with static images. In GTK rendering mode, it will show the standard button // with GTK |stock_id|. @@ -129,7 +162,7 @@ class CustomDrawButton : public NotificationObserver { // Set the background details. void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); - // Provide NotificationObserver implementation. + // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); @@ -152,6 +185,8 @@ class CustomDrawButton : public NotificationObserver { CustomDrawButtonBase button_base_; + CustomDrawHoverController hover_controller_; + // Our theme provider. GtkThemeProvider* theme_provider_; diff --git a/chrome/browser/gtk/go_button_gtk.cc b/chrome/browser/gtk/go_button_gtk.cc index c865c36..0bfb416 100644 --- a/chrome/browser/gtk/go_button_gtk.cc +++ b/chrome/browser/gtk/go_button_gtk.cc @@ -30,7 +30,6 @@ GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser) stop_timer_(this), intended_mode_(MODE_GO), visible_mode_(MODE_GO), - state_(BS_NORMAL), theme_provider_(browser ? GtkThemeProvider::GetFrom(browser->profile()) : NULL), go_(theme_provider_, IDR_GO, IDR_GO_P, IDR_GO_H, 0, IDR_GO_MASK), @@ -39,14 +38,10 @@ GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser) gtk_widget_set_size_request(widget_.get(), go_.Width(), go_.Height()); gtk_widget_set_app_paintable(widget_.get(), TRUE); - // We effectively double-buffer by virtue of having only one image... - gtk_widget_set_double_buffered(widget_.get(), FALSE); g_signal_connect(widget_.get(), "expose-event", G_CALLBACK(OnExpose), this); - g_signal_connect(widget_.get(), "enter", - G_CALLBACK(OnEnter), this); - g_signal_connect(widget_.get(), "leave", + g_signal_connect(widget_.get(), "leave-notify-event", G_CALLBACK(OnLeave), this); g_signal_connect(widget_.get(), "clicked", G_CALLBACK(OnClicked), this); @@ -56,6 +51,7 @@ GoButtonGtk::GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser) g_signal_connect(widget_.get(), "query-tooltip", G_CALLBACK(OnQueryTooltipThunk), this); + hover_controller_.Init(widget()); gtk_util::SetButtonTriggersNavigation(widget()); if (theme_provider_) { @@ -76,8 +72,9 @@ void GoButtonGtk::ChangeMode(Mode mode, bool force) { // If the change is forced, or the user isn't hovering the icon, or it's safe // to change it to the other image type, make the change immediately; // otherwise we'll let it happen later. - if (force || (state() != BS_HOT) || ((mode == MODE_STOP) ? - stop_timer_.empty() : (visible_mode_ != MODE_STOP))) { + if (force || GTK_WIDGET_STATE(widget()) == GTK_STATE_NORMAL || + ((mode == MODE_STOP) ? + stop_timer_.empty() : (visible_mode_ != MODE_STOP))) { stop_timer_.RevokeAll(); visible_mode_ = mode; gtk_widget_queue_draw(widget_.get()); @@ -112,34 +109,21 @@ gboolean GoButtonGtk::OnExpose(GtkWidget* widget, if (button->theme_provider_ && button->theme_provider_->UseGtkTheme()) { return FALSE; } else { + double hover_state = button->hover_controller_.GetCurrentValue(); if (button->visible_mode_ == MODE_GO) { - return button->go_.OnExpose(widget, e); + return button->go_.OnExpose(widget, e, hover_state); } else { - return button->stop_.OnExpose(widget, e); + return button->stop_.OnExpose(widget, e, hover_state); } } } // static -gboolean GoButtonGtk::OnEnter(GtkButton* widget, GoButtonGtk* button) { - DCHECK_EQ(BS_NORMAL, button->state()); - button->state_ = BS_HOT; - return TRUE; -} - -// static -gboolean GoButtonGtk::OnLeave(GtkButton* widget, GoButtonGtk* button) { - // It's possible on shutdown for a "leave" event to be emitted twice in a row - // for this button. I'm not sure if this is a gtk quirk or something wrong - // with our usage, but it's harmless. I'm commenting out this DCHECK for now. - // and adding a LOG(WARNING) instead. - // See http://www.crbug.com/10851 for details. - // DCHECK_EQ(BS_HOT, button->state()); - if (button->state() != BS_HOT) - LOG(WARNING) << "Button state should be BS_HOT when leaving."; - button->state_ = BS_NORMAL; +gboolean GoButtonGtk::OnLeave(GtkWidget* widget, + GdkEventCrossing* event, + GoButtonGtk* button) { button->ChangeMode(button->intended_mode_, true); - return TRUE; + return FALSE; } // static diff --git a/chrome/browser/gtk/go_button_gtk.h b/chrome/browser/gtk/go_button_gtk.h index 3c3522d..adf5f06 100644 --- a/chrome/browser/gtk/go_button_gtk.h +++ b/chrome/browser/gtk/go_button_gtk.h @@ -22,13 +22,11 @@ class Task; class GoButtonGtk : public NotificationObserver { public: enum Mode { MODE_GO = 0, MODE_STOP }; - enum ButtonState { BS_NORMAL = 0, BS_HOT }; GoButtonGtk(LocationBarViewGtk* location_bar, Browser* browser); ~GoButtonGtk(); GtkWidget* widget() const { return widget_.get(); } - ButtonState state() const { return state_; } // Ask for a specified button state. If |force| is true this will be applied // immediately. @@ -46,8 +44,8 @@ class GoButtonGtk : public NotificationObserver { static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, GoButtonGtk* button); - static gboolean OnEnter(GtkButton* widget, GoButtonGtk* button); - static gboolean OnLeave(GtkButton* widget, GoButtonGtk* button); + static gboolean OnLeave(GtkWidget* widget, GdkEventCrossing* event, + GoButtonGtk* button); static gboolean OnClicked(GtkButton* widget, GoButtonGtk* button); static gboolean OnQueryTooltipThunk(GtkWidget* widget, gint x, gint y, gboolean keyboard_mode, @@ -82,12 +80,11 @@ class GoButtonGtk : public NotificationObserver { // The currently-visible mode - this may different from the intended mode. Mode visible_mode_; - ButtonState state_; - GtkThemeProvider* theme_provider_; CustomDrawButtonBase go_; CustomDrawButtonBase stop_; + CustomDrawHoverController hover_controller_; OwnedWidgetGtk widget_; diff --git a/chrome/browser/gtk/go_button_gtk_unittest.cc b/chrome/browser/gtk/go_button_gtk_unittest.cc index 2e2f027..fd0eb17 100644 --- a/chrome/browser/gtk/go_button_gtk_unittest.cc +++ b/chrome/browser/gtk/go_button_gtk_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,15 +19,18 @@ class GoButtonGtkPeer { return &go_->stop_timer_; } + void SetState(GtkStateType state) { + gtk_widget_set_state(go_->widget(), state); + } + // mutators for internal state - void set_state(GoButtonGtk::ButtonState state) { go_->state_ = state; } void set_intended_mode(GoButtonGtk::Mode mode) { go_->intended_mode_ = mode; } void set_visible_mode(GoButtonGtk::Mode mode) { go_->visible_mode_ = mode; } // forwarders to private methods Task* CreateButtonTimerTask() { return go_->CreateButtonTimerTask(); } gboolean OnLeave() { - return GoButtonGtk::OnLeave(GTK_BUTTON(go_->widget()), go_); + return GoButtonGtk::OnLeave(go_->widget(), NULL, go_); } gboolean OnClicked() { @@ -63,7 +66,7 @@ TEST_F(GoButtonGtkTest, ChangeModeStop) { TEST_F(GoButtonGtkTest, ScheduleChangeModeNormalGo) { peer_.set_visible_mode(GoButtonGtk::MODE_STOP); - peer_.set_state(GoButtonGtk::BS_NORMAL); + peer_.SetState(GTK_STATE_NORMAL); go_.ChangeMode(GoButtonGtk::MODE_GO, false); EXPECT_EQ(GoButtonGtk::MODE_GO, peer_.intended_mode()); EXPECT_EQ(GoButtonGtk::MODE_GO, peer_.visible_mode()); @@ -71,7 +74,7 @@ TEST_F(GoButtonGtkTest, ScheduleChangeModeNormalGo) { TEST_F(GoButtonGtkTest, ScheduleChangeModeHotGo) { peer_.set_visible_mode(GoButtonGtk::MODE_STOP); - peer_.set_state(GoButtonGtk::BS_HOT); + peer_.SetState(GTK_STATE_PRELIGHT); go_.ChangeMode(GoButtonGtk::MODE_GO, false); EXPECT_EQ(GoButtonGtk::MODE_GO, peer_.intended_mode()); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.visible_mode()); @@ -79,7 +82,7 @@ TEST_F(GoButtonGtkTest, ScheduleChangeModeHotGo) { TEST_F(GoButtonGtkTest, ScheduleChangeModeNormalStop) { peer_.set_visible_mode(GoButtonGtk::MODE_GO); - peer_.set_state(GoButtonGtk::BS_NORMAL); + peer_.SetState(GTK_STATE_NORMAL); go_.ChangeMode(GoButtonGtk::MODE_STOP, false); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.intended_mode()); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.visible_mode()); @@ -87,7 +90,7 @@ TEST_F(GoButtonGtkTest, ScheduleChangeModeNormalStop) { TEST_F(GoButtonGtkTest, ScheduleChangeModeHotStop) { peer_.set_visible_mode(GoButtonGtk::MODE_GO); - peer_.set_state(GoButtonGtk::BS_HOT); + peer_.SetState(GTK_STATE_PRELIGHT); go_.ChangeMode(GoButtonGtk::MODE_STOP, false); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.intended_mode()); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.visible_mode()); @@ -95,7 +98,7 @@ TEST_F(GoButtonGtkTest, ScheduleChangeModeHotStop) { TEST_F(GoButtonGtkTest, ScheduleChangeModeTimerHotStop) { peer_.set_visible_mode(GoButtonGtk::MODE_GO); - peer_.set_state(GoButtonGtk::BS_HOT); + peer_.SetState(GTK_STATE_PRELIGHT); scoped_ptr<Task> task(peer_.CreateButtonTimerTask()); go_.ChangeMode(GoButtonGtk::MODE_STOP, false); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.intended_mode()); @@ -103,19 +106,19 @@ TEST_F(GoButtonGtkTest, ScheduleChangeModeTimerHotStop) { } TEST_F(GoButtonGtkTest, OnLeaveIntendedStop) { - peer_.set_state(GoButtonGtk::BS_HOT); + peer_.SetState(GTK_STATE_PRELIGHT); peer_.set_visible_mode(GoButtonGtk::MODE_GO); peer_.set_intended_mode(GoButtonGtk::MODE_STOP); - EXPECT_TRUE(peer_.OnLeave()); + peer_.OnLeave(); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.visible_mode()); EXPECT_EQ(GoButtonGtk::MODE_STOP, peer_.intended_mode()); } TEST_F(GoButtonGtkTest, OnLeaveIntendedGo) { - peer_.set_state(GoButtonGtk::BS_HOT); + peer_.SetState(GTK_STATE_PRELIGHT); peer_.set_visible_mode(GoButtonGtk::MODE_STOP); peer_.set_intended_mode(GoButtonGtk::MODE_GO); - EXPECT_TRUE(peer_.OnLeave()); + peer_.OnLeave(); EXPECT_EQ(GoButtonGtk::MODE_GO, peer_.visible_mode()); EXPECT_EQ(GoButtonGtk::MODE_GO, peer_.intended_mode()); } diff --git a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc index e709d7b..e6b983a 100644 --- a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc +++ b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,7 @@ ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host) g_signal_connect(widget(), "expose-event", G_CALLBACK(OnExpose), this); - GTK_WIDGET_UNSET_FLAGS(widget_.get(), GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS(widget(), GTK_CAN_FOCUS); gtk_drag_source_set(widget(), GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK)); @@ -51,6 +51,8 @@ ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host) registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); + + hover_controller_.Init(widget()); } ToolbarStarToggleGtk::~ToolbarStarToggleGtk() { @@ -89,11 +91,11 @@ gboolean ToolbarStarToggleGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, if (button->theme_provider_->UseGtkTheme()) { return FALSE; } else { - if (button->is_starred_) { - return button->starred_.OnExpose(widget, e); - } else { - return button->unstarred_.OnExpose(widget, e); - } + double hover_state = button->hover_controller_.GetCurrentValue(); + if (button->is_starred_) + return button->starred_.OnExpose(widget, e, hover_state); + else + return button->unstarred_.OnExpose(widget, e, hover_state); } } diff --git a/chrome/browser/gtk/toolbar_star_toggle_gtk.h b/chrome/browser/gtk/toolbar_star_toggle_gtk.h index 66aa167..faa025a 100644 --- a/chrome/browser/gtk/toolbar_star_toggle_gtk.h +++ b/chrome/browser/gtk/toolbar_star_toggle_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,8 +68,9 @@ class ToolbarStarToggleGtk : public NotificationObserver { CustomDrawButtonBase unstarred_; CustomDrawButtonBase starred_; + CustomDrawHoverController hover_controller_; - DISALLOW_EVIL_CONSTRUCTORS(ToolbarStarToggleGtk); + DISALLOW_COPY_AND_ASSIGN(ToolbarStarToggleGtk); }; #endif // CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ |