Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1133)

Unified Diff: chrome/browser/ui/gtk/slide_animator_gtk.h

Issue 6099014: Move chrome/browser/gtk to chrome/browser/ui/gtk (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move browser/gtk/ to browser/ui/gtk/, leave header stubs, update new header guards Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/sad_tab_gtk.cc ('k') | chrome/browser/ui/gtk/slide_animator_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/slide_animator_gtk.h
diff --git a/chrome/browser/ui/gtk/slide_animator_gtk.h b/chrome/browser/ui/gtk/slide_animator_gtk.h
new file mode 100644
index 0000000000000000000000000000000000000000..b3390b4d9abdea4b791008926c7634ba7fc72375
--- /dev/null
+++ b/chrome/browser/ui/gtk/slide_animator_gtk.h
@@ -0,0 +1,123 @@
+// Copyright (c) 2009 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.
+//
+// A helper class for animating the display of native widget content.
+// Currently only handle vertical sliding, but could be extended to handle
+// horizontal slides or other types of animations.
+//
+// NOTE: This does not handle clipping. If you are not careful, you will
+// wind up with visibly overlapping widgets. If you need clipping, you can
+// extend the constructor to take an option to give |fixed| its own GdkWindow
+// (via gtk_fixed_set_has_window).
+
+#ifndef CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_
+#define CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/gtk/owned_widget_gtk.h"
+#include "ui/base/animation/animation_delegate.h"
+
+namespace ui {
+class SlideAnimation;
+}
+
+class SlideAnimatorGtk : public ui::AnimationDelegate {
+ public:
+ class Delegate {
+ public:
+ // Called when a call to Close() finishes animating.
+ virtual void Closed() = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
+ enum Direction {
+ DOWN,
+ UP
+ };
+
+ // |child| is the widget we pack into |widget_|.
+ // |direction| indicates which side the contents will appear to come from.
+ // |duration| is the duration of the slide in milliseconds, or 0 for default.
+ // |linear| controls how the animation progresses. If true, the
+ // velocity of the slide is constant over time, otherwise it goes a bit faster
+ // at the beginning and slows to a halt.
+ // |delegate| may be NULL.
+ SlideAnimatorGtk(GtkWidget* child,
+ Direction direction,
+ int duration,
+ bool linear,
+ bool control_child_size,
+ Delegate* delegate);
+
+ virtual ~SlideAnimatorGtk();
+
+ GtkWidget* widget() { return widget_.get(); }
+
+ // Slide open.
+ void Open();
+
+ // Immediately show the widget.
+ void OpenWithoutAnimation();
+
+ // Slide shut.
+ void Close();
+
+ // End the current animation.
+ void End();
+
+ // Immediately hide the widget.
+ void CloseWithoutAnimation();
+
+ // Returns whether the widget is visible.
+ bool IsShowing();
+
+ // Returns whether the widget is currently showing the close animation.
+ bool IsClosing();
+
+ // Returns whether the widget is currently showing the open or close
+ // animation.
+ bool IsAnimating();
+
+ // ui::AnimationDelegate implementation.
+ virtual void AnimationProgressed(const ui::Animation* animation);
+ virtual void AnimationEnded(const ui::Animation* animation);
+
+ // Used during testing; disable or enable animations (default is enabled).
+ static void SetAnimationsForTesting(bool enable);
+
+ private:
+ static void OnChildSizeAllocate(GtkWidget* child,
+ GtkAllocation* allocation,
+ SlideAnimatorGtk* slider);
+
+ scoped_ptr<ui::SlideAnimation> animation_;
+
+ // The top level widget of the SlideAnimatorGtk. It is a GtkFixed.
+ OwnedWidgetGtk widget_;
+
+ // The widget passed to us at construction time, and the only direct child of
+ // |widget_|.
+ GtkWidget* child_;
+
+ // The direction of the slide.
+ Direction direction_;
+
+ // The object to inform about certain events. It may be NULL.
+ Delegate* delegate_;
+
+ // We need to move the child widget to (0, -height), but we don't know its
+ // height until it has been allocated. This variable will be true until the
+ // child widget has been allocated, at which point we will move it, and then
+ // set this variable to false to indicate it should not be moved again.
+ bool child_needs_move_;
+
+ static bool animations_enabled_;
+};
+
+#endif // CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_
« no previous file with comments | « chrome/browser/ui/gtk/sad_tab_gtk.cc ('k') | chrome/browser/ui/gtk/slide_animator_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698