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

Side by Side Diff: views/animator.h

Issue 42490: Experiments with a new tabstrip + animator (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 unified diff | Download patch
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | views/animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #ifndef VIEWS_ANIMATOR_H_
6 #define VIEWS_ANIMATOR_H_
7
8 #include <xutility>
9
10 #include "app/animation.h"
11 #include "base/gfx/rect.h"
12 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h"
14
15 class SlideAnimation;
16
17 ////////////////////////////////////////////////////////////////////////////////
18 // ALERT!
19 //
20 // This API is preliminary and subject to change. Talk to beng before using it!
21 //
22
23 namespace views {
24
25 class View;
26
27 class AnimatorDelegate {
28 public:
29 // Returns the view in the visual layout whose trailing edge the view that
30 // hosts an animator should be clamped to during animations, when
31 // ANIMATE_CLAMP is specified in combination with ANIMATE_X or ANIMATE_Y.
32 virtual View* GetClampedView(View* host) = 0;
33
34 // Notifies the delegate that the active animation running for |host| has
35 // completed.
36 virtual void AnimationCompletedForHost(View* host) = 0;
37 };
38
39 // An animator is an object that can animate actions on a host view. Once
40 // created, an Animator is typically owned by its host view.
41 class Animator : public AnimationDelegate {
42 public:
43 enum BoundsChangeFlags {
44 ANIMATE_NONE = 0x0, // Don't animate anything... o_O
45 ANIMATE_X = 0x1, // Animate the host view's x position
46 ANIMATE_Y = 0x2, // Animate the host view's y position
47 ANIMATE_WIDTH = 0x4, // Animate the host view's width
48 ANIMATE_HEIGHT = 0x8, // Animate the host view's height
49 ANIMATE_CLAMP = 0x10 // Clamp the host view's x or y position to the
50 // trailing edge of the view returned by
51 // AnimatorDelegate::GetClampedView.
52 };
53
54 // Creates the animator for the specified host view. Optionally an
55 // AnimationContext can be provided to animate multiple views from a single
56 // animation.
57 explicit Animator(View* host);
58 Animator(View* host, AnimatorDelegate* delegate);
59 virtual ~Animator();
60
61 // Returns true if the animator is currently animating.
62 bool IsAnimating() const;
63
64 // Moves/sizes the host view to the specified bounds. |direction| is a
65 // combination of the above flags indicating what aspects of the bounds should
66 // be animated.
67 void AnimateToBounds(const gfx::Rect& bounds, int direction);
68 void AnimateToBounds(int x, int y, int width, int height, int direction) {
69 AnimateToBounds(gfx::Rect(x, y, std::max(0, width), std::max(0, height)),
70 direction);
71 }
72
73 // Overridden from AnimationDelegate:
74 virtual void AnimationEnded(const Animation* animation);
75 virtual void AnimationProgressed(const Animation* animation);
76 virtual void AnimationCanceled(const Animation* animation);
77
78 private:
79 void InitAnimation();
80
81 // Get the current X/Y position of the host view, clamped to the right edge of
82 // the previous view in the visual layout, if applicable (See
83 // AnimatorDelegate for more info).
84 int GetClampedX() const;
85 int GetClampedY() const;
86
87 // The view that this animator is attached to.
88 View* host_;
89
90 // Start and end bounds for the animation.
91 gfx::Rect start_bounds_;
92 gfx::Rect target_bounds_;
93
94 // The animation used by this animator.
95 scoped_ptr<SlideAnimation> animation_;
96
97 // A delegate object that provides information about surrounding views.
98 // Will be NULL during this class' destructor.
99 AnimatorDelegate* delegate_;
100
101 // Some combination of BoundsChangeFlags indicating the type of bounds change
102 // the host view is subject to.
103 int direction_;
104
105 DISALLOW_COPY_AND_ASSIGN(Animator);
106 };
107
108 } // namespace views
109
110 #endif // #ifndef VIEWS_ANIMATOR_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | views/animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698