Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / hover_controller_gtk.h
blob879b91757eb29128f878e6f3ca827b6dc9125f44
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_HOVER_CONTROLLER_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_HOVER_CONTROLLER_GTK_H_
8 #include <gtk/gtk.h>
10 #include "base/compiler_specific.h"
11 #include "ui/base/gtk/gtk_signal.h"
12 #include "ui/base/gtk/gtk_signal_registrar.h"
13 #include "ui/gfx/animation/animation_delegate.h"
14 #include "ui/gfx/animation/slide_animation.h"
15 #include "ui/gfx/animation/throb_animation.h"
17 // This class handles the "throbbing" of a GtkChromeButton. The visual effect
18 // of throbbing is created by painting partially transparent hover effects. It
19 // only works in non-gtk theme mode. This class mainly exists to glue an
20 // AnimationDelegate (C++ class) to a GtkChromeButton* (GTK/c object).
21 class HoverControllerGtk : public gfx::AnimationDelegate {
22 public:
23 virtual ~HoverControllerGtk();
25 GtkWidget* button() { return button_; }
27 // Throb for |cycles| cycles. This will override the current remaining
28 // number of cycles. Note that a "cycle" is (somewhat unintuitively) half of
29 // a complete throb revolution.
30 void StartThrobbing(int cycles);
32 // Get the HoverControllerGtk for a given GtkChromeButton*. It is an error
33 // to call this on a widget that is not a GtkChromeButton*.
34 static HoverControllerGtk* GetHoverControllerGtk(GtkWidget* button);
36 // Creates a GtkChromeButton and adds a HoverControllerGtk for it.
37 static GtkWidget* CreateChromeButton();
39 // Stop throbbing and delete |this|.
40 void Destroy();
42 private:
43 explicit HoverControllerGtk(GtkWidget* button);
45 // Overridden from gfx::AnimationDelegate.
46 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
47 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
48 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
50 CHROMEGTK_CALLBACK_1(HoverControllerGtk, gboolean, OnEnter,
51 GdkEventCrossing*);
52 CHROMEGTK_CALLBACK_1(HoverControllerGtk, gboolean, OnLeave,
53 GdkEventCrossing*);
54 CHROMEGTK_CALLBACK_1(HoverControllerGtk, void, OnHierarchyChanged,
55 GtkWidget*);
56 CHROMEGTK_CALLBACK_0(HoverControllerGtk, void, OnDestroy);
58 gfx::ThrobAnimation throb_animation_;
59 gfx::SlideAnimation hover_animation_;
60 GtkWidget* button_;
62 ui::GtkSignalRegistrar signals_;
64 DISALLOW_COPY_AND_ASSIGN(HoverControllerGtk);
67 #endif // CHROME_BROWSER_UI_GTK_HOVER_CONTROLLER_GTK_H_