| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" | 5 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 8 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 9 #include "ui/gfx/gtk_compat.h" | 9 #include "ui/gfx/gtk_compat.h" |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void HoverControllerGtk::Destroy() { | 58 void HoverControllerGtk::Destroy() { |
| 59 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), -1.0); | 59 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), -1.0); |
| 60 | 60 |
| 61 g_object_set_data(G_OBJECT(button_), kHoverControllerGtkKey, NULL); | 61 g_object_set_data(G_OBJECT(button_), kHoverControllerGtkKey, NULL); |
| 62 g_object_unref(button_); | 62 g_object_unref(button_); |
| 63 button_ = NULL; | 63 button_ = NULL; |
| 64 | 64 |
| 65 delete this; | 65 delete this; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void HoverControllerGtk::AnimationProgressed(const ui::Animation* animation) { | 68 void HoverControllerGtk::AnimationProgressed(const gfx::Animation* animation) { |
| 69 if (!button_) | 69 if (!button_) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 // Ignore the hover animation if we are throbbing. | 72 // Ignore the hover animation if we are throbbing. |
| 73 if (animation == &hover_animation_ && throb_animation_.is_animating()) | 73 if (animation == &hover_animation_ && throb_animation_.is_animating()) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), | 76 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), |
| 77 animation->GetCurrentValue()); | 77 animation->GetCurrentValue()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void HoverControllerGtk::AnimationEnded(const ui::Animation* animation) { | 80 void HoverControllerGtk::AnimationEnded(const gfx::Animation* animation) { |
| 81 if (!button_) | 81 if (!button_) |
| 82 return; | 82 return; |
| 83 if (animation != &throb_animation_) | 83 if (animation != &throb_animation_) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 if (throb_animation_.cycles_remaining() <= 1) | 86 if (throb_animation_.cycles_remaining() <= 1) |
| 87 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0); | 87 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void HoverControllerGtk::AnimationCanceled(const ui::Animation* animation) { | 90 void HoverControllerGtk::AnimationCanceled(const gfx::Animation* animation) { |
| 91 AnimationEnded(animation); | 91 AnimationEnded(animation); |
| 92 } | 92 } |
| 93 | 93 |
| 94 gboolean HoverControllerGtk::OnEnter(GtkWidget* widget, | 94 gboolean HoverControllerGtk::OnEnter(GtkWidget* widget, |
| 95 GdkEventCrossing* event) { | 95 GdkEventCrossing* event) { |
| 96 hover_animation_.Show(); | 96 hover_animation_.Show(); |
| 97 | 97 |
| 98 return FALSE; | 98 return FALSE; |
| 99 } | 99 } |
| 100 | 100 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget))) { | 118 if (!gtk_widget_is_toplevel(gtk_widget_get_toplevel(widget))) { |
| 119 gtk_widget_set_state(button_, GTK_STATE_NORMAL); | 119 gtk_widget_set_state(button_, GTK_STATE_NORMAL); |
| 120 hover_animation_.Reset(); | 120 hover_animation_.Reset(); |
| 121 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0.0); | 121 gtk_chrome_button_set_hover_state(GTK_CHROME_BUTTON(button_), 0.0); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 void HoverControllerGtk::OnDestroy(GtkWidget* widget) { | 125 void HoverControllerGtk::OnDestroy(GtkWidget* widget) { |
| 126 Destroy(); | 126 Destroy(); |
| 127 } | 127 } |
| OLD | NEW |