summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/throb_controller_gtk.h
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 01:18:29 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 01:18:29 +0000
commit2ca77d23336c7ff61b7856aed33197df1e851edb (patch)
tree8b8ad47ff6eafc1ab017e843e595d6e18f62ab97 /chrome/browser/gtk/throb_controller_gtk.h
parent1f7b4176c3b8db732c8cc1842283d78908aa9cf6 (diff)
downloadchromium_src-2ca77d23336c7ff61b7856aed33197df1e851edb.zip
chromium_src-2ca77d23336c7ff61b7856aed33197df1e851edb.tar.gz
chromium_src-2ca77d23336c7ff61b7856aed33197df1e851edb.tar.bz2
GTK: throb a bookmark folder button when a URL is added to it.
BUG=16782 TEST=add bookmark as a descendant of a bookmark bar folder node, watch it throb. Clicking it should make the throbbing stop. Review URL: http://codereview.chromium.org/543201 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/throb_controller_gtk.h')
-rw-r--r--chrome/browser/gtk/throb_controller_gtk.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/chrome/browser/gtk/throb_controller_gtk.h b/chrome/browser/gtk/throb_controller_gtk.h
new file mode 100644
index 0000000..9b596cc
--- /dev/null
+++ b/chrome/browser/gtk/throb_controller_gtk.h
@@ -0,0 +1,67 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GTK_THROB_CONTROLLER_GTK_H_
+#define CHROME_BROWSER_GTK_THROB_CONTROLLER_GTK_H_
+
+#include "app/throb_animation.h"
+#include "base/scoped_ptr.h"
+
+typedef struct _GtkWidget GtkWidget;
+
+// This class handles the "throbbing" of a GtkChromeButton. The visual effect
+// of throbbing is created by painting partially transparent hover effects. It
+// only works in non-gtk theme mode. This class mainly exists to glue an
+// AnimationDelegate (C++ class) to a GtkChromeButton* (GTK/c object). Usage is
+// as follows:
+//
+// GtkWidget* button = gtk_chrome_button_new();
+// ThrobControllerGtk::ThrobFor(button);
+//
+// The ThrobFor() function will handle creation of the ThrobControllerGtk
+// object, which will delete itself automatically when the throbbing is done,
+// or when the widget is destroyed. It may also be canceled prematurely with
+//
+// ThrobControllerGtk* throbber =
+// ThrobControllerGtk::GetThrobControllerGtk(button);
+// throbber->Destroy();
+class ThrobControllerGtk : public AnimationDelegate {
+ public:
+ virtual ~ThrobControllerGtk();
+
+ GtkWidget* button() { return button_; }
+
+ // Throb for |cycles| cycles. This will override the current remaining
+ // number of cycles.
+ void StartThrobbing(int cycles);
+
+ // Get the ThrobControllerGtk for a given GtkChromeButton*. It is an error
+ // to call this on a widget that is not a GtkChromeButton*.
+ static ThrobControllerGtk* GetThrobControllerGtk(GtkWidget* button);
+
+ // Make |button| throb. It is an error to try to have two ThrobControllerGtk
+ // instances for one GtkChromeButton*.
+ static void ThrobFor(GtkWidget* button);
+
+ // Stop throbbing and delete |this|.
+ void Destroy();
+
+ private:
+ explicit ThrobControllerGtk(GtkWidget* button);
+
+ // Overridden from AnimationDelegate.
+ virtual void AnimationProgressed(const Animation* animation);
+ virtual void AnimationEnded(const Animation* animation);
+ virtual void AnimationCanceled(const Animation* animation);
+
+ static void OnButtonDestroy(GtkWidget* widget,
+ ThrobControllerGtk* button);
+
+ ThrobAnimation animation_;
+ GtkWidget* button_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThrobControllerGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_THROB_CONTROLLER_GTK_H_