summaryrefslogtreecommitdiffstats
path: root/views/animator.h
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 18:44:31 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 18:44:31 +0000
commit7c0560f904487819f2c408c87899d1ccfa91c1fe (patch)
treeda949466cd6dd09f5ce575b206a65b6ba0e1a2f9 /views/animator.h
parent93a2c7241cddc33af51cdc3daea03e414f544ec8 (diff)
downloadchromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.zip
chromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.tar.gz
chromium_src-7c0560f904487819f2c408c87899d1ccfa91c1fe.tar.bz2
Basics of a new TabStrip.It's very, very rough, but I wanted to check it in so I don't have to keep typing svn pset as I pass patches back and forth between machines.Behind a command line flag --enable-tabtastic2.I'm trying to split the TabContents specific stuff off of the TabStrip so it's more generic (and more easily mocked for unit testing of various layout conditions). Hence TabStrip vs. BrowserTabStrip. TabStrip may move into views/ once this process is complete.Animator is a utility that can be associated with a View that (at this point) animates that View's bounds from wherever it is now to somewhere else. The TabStrip uses this to do animations for individual Tabs that are independent of each other - a limitation of the old TabStrip is that only one animation is ever active at a time so its animations are a little jumpy compared to other products.Also, detached tab dragging shows the live contents, with all animations/video/etc.Like I said, this is really rough, but I didn't want it to grow any bigger. I will write up a design doc later.http://crbug.com/9032TEST=TBD... will finally be doing some for TabStrip layout!
Review URL: http://codereview.chromium.org/42490 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/animator.h')
-rw-r--r--views/animator.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/views/animator.h b/views/animator.h
new file mode 100644
index 0000000..2719fd6
--- /dev/null
+++ b/views/animator.h
@@ -0,0 +1,110 @@
+// 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.
+
+#ifndef VIEWS_ANIMATOR_H_
+#define VIEWS_ANIMATOR_H_
+
+#include <xutility>
+
+#include "app/animation.h"
+#include "base/gfx/rect.h"
+#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
+
+class SlideAnimation;
+
+////////////////////////////////////////////////////////////////////////////////
+// ALERT!
+//
+// This API is preliminary and subject to change. Talk to beng before using it!
+//
+
+namespace views {
+
+class View;
+
+class AnimatorDelegate {
+ public:
+ // Returns the view in the visual layout whose trailing edge the view that
+ // hosts an animator should be clamped to during animations, when
+ // ANIMATE_CLAMP is specified in combination with ANIMATE_X or ANIMATE_Y.
+ virtual View* GetClampedView(View* host) = 0;
+
+ // Notifies the delegate that the active animation running for |host| has
+ // completed.
+ virtual void AnimationCompletedForHost(View* host) = 0;
+};
+
+// An animator is an object that can animate actions on a host view. Once
+// created, an Animator is typically owned by its host view.
+class Animator : public AnimationDelegate {
+ public:
+ enum BoundsChangeFlags {
+ ANIMATE_NONE = 0x0, // Don't animate anything... o_O
+ ANIMATE_X = 0x1, // Animate the host view's x position
+ ANIMATE_Y = 0x2, // Animate the host view's y position
+ ANIMATE_WIDTH = 0x4, // Animate the host view's width
+ ANIMATE_HEIGHT = 0x8, // Animate the host view's height
+ ANIMATE_CLAMP = 0x10 // Clamp the host view's x or y position to the
+ // trailing edge of the view returned by
+ // AnimatorDelegate::GetClampedView.
+ };
+
+ // Creates the animator for the specified host view. Optionally an
+ // AnimationContext can be provided to animate multiple views from a single
+ // animation.
+ explicit Animator(View* host);
+ Animator(View* host, AnimatorDelegate* delegate);
+ virtual ~Animator();
+
+ // Returns true if the animator is currently animating.
+ bool IsAnimating() const;
+
+ // Moves/sizes the host view to the specified bounds. |direction| is a
+ // combination of the above flags indicating what aspects of the bounds should
+ // be animated.
+ void AnimateToBounds(const gfx::Rect& bounds, int direction);
+ void AnimateToBounds(int x, int y, int width, int height, int direction) {
+ AnimateToBounds(gfx::Rect(x, y, std::max(0, width), std::max(0, height)),
+ direction);
+ }
+
+ // Overridden from AnimationDelegate:
+ virtual void AnimationEnded(const Animation* animation);
+ virtual void AnimationProgressed(const Animation* animation);
+ virtual void AnimationCanceled(const Animation* animation);
+
+ private:
+ void InitAnimation();
+
+ // Get the current X/Y position of the host view, clamped to the right edge of
+ // the previous view in the visual layout, if applicable (See
+ // AnimatorDelegate for more info).
+ int GetClampedX() const;
+ int GetClampedY() const;
+
+ // The view that this animator is attached to.
+ View* host_;
+
+ // Start and end bounds for the animation.
+ gfx::Rect start_bounds_;
+ gfx::Rect target_bounds_;
+
+ // The animation used by this animator.
+ scoped_ptr<SlideAnimation> animation_;
+
+ // A delegate object that provides information about surrounding views.
+ // Will be NULL during this class' destructor.
+ AnimatorDelegate* delegate_;
+
+ // Some combination of BoundsChangeFlags indicating the type of bounds change
+ // the host view is subject to.
+ int direction_;
+
+ DISALLOW_COPY_AND_ASSIGN(Animator);
+};
+
+} // namespace views
+
+#endif // #ifndef VIEWS_ANIMATOR_H_