Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// 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.


#include <gtk/gtk.h>

#include "app/slide_animation.h"
#include "app/throb_animation.h"
#include "base/scoped_ptr.h"

// 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).
class HoverControllerGtk : public AnimationDelegate {
  virtual ~HoverControllerGtk();

  GtkWidget* button() { return button_; }

  // Throb for |cycles| cycles. This will override the current remaining
  // number of cycles. Note that a "cycle" is (somewhat unintuitively) half of
  // a complete throb revolution.
  void StartThrobbing(int cycles);

  // Get the HoverControllerGtk for a given GtkChromeButton*. It is an error
  // to call this on a widget that is not a GtkChromeButton*.
  static HoverControllerGtk* GetHoverControllerGtk(GtkWidget* button);

  // Creates a GtkChromeButton and adds a HoverControllerGtk for it.
  static GtkWidget* CreateChromeButton();

  // Stop throbbing and delete |this|.
  void Destroy();

  explicit HoverControllerGtk(GtkWidget* button);

  // Overridden from AnimationDelegate.
  virtual void AnimationProgressed(const Animation* animation);
  virtual void AnimationEnded(const Animation* animation);
  virtual void AnimationCanceled(const Animation* animation);

  static gboolean OnEnterThunk(GtkWidget* widget,
                               GdkEventCrossing* event,
                               HoverControllerGtk* hover_controller) {
    return hover_controller->OnEnter(widget, event);
  gboolean OnEnter(GtkWidget* widget, GdkEventCrossing* event);

  static gboolean OnLeaveThunk(GtkWidget* widget,
                               GdkEventCrossing* event,
                               HoverControllerGtk* hover_controller) {
    return hover_controller->OnLeave(widget, event);
  gboolean OnLeave(GtkWidget* widget, GdkEventCrossing* event);

  static void OnButtonDestroyThunk(GtkWidget* widget,
                                   HoverControllerGtk* hover_controller) {
  void OnButtonDestroy(GtkWidget* widget);

  ThrobAnimation throb_animation_;
  SlideAnimation hover_animation_;
  GtkWidget* button_;



Generated by  Doxygen 1.6.0   Back to index