OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // A helper class for animating the display of native widget content. | 5 // A helper class for animating the display of native widget content. |
6 // Currently only handle vertical sliding, but could be extended to handle | 6 // Currently only handle vertical sliding, but could be extended to handle |
7 // horizontal slides or other types of animations. | 7 // horizontal slides or other types of animations. |
8 | 8 |
9 #ifndef CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ | 9 #ifndef CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ |
10 #define CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ | 10 #define CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ |
11 | 11 |
| 12 #include <gtk/gtk.h> |
| 13 |
12 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
13 #include "chrome/common/animation.h" | 15 #include "chrome/common/animation.h" |
14 #include "chrome/common/owned_widget_gtk.h" | 16 #include "chrome/common/owned_widget_gtk.h" |
15 | 17 |
16 class SlideAnimation; | 18 class SlideAnimation; |
17 | 19 |
18 typedef struct _GtkWidget GtkWidget; | |
19 | |
20 class SlideAnimatorGtk : public AnimationDelegate { | 20 class SlideAnimatorGtk : public AnimationDelegate { |
21 public: | 21 public: |
22 class Delegate { | 22 class Delegate { |
23 public: | 23 public: |
24 // Called when a call to Close() finishes animating. | 24 // Called when a call to Close() finishes animating. |
25 virtual void Closed() = 0; | 25 virtual void Closed() = 0; |
26 }; | 26 }; |
27 | 27 |
28 enum Direction { | 28 enum Direction { |
29 DOWN, | 29 DOWN, |
(...skipping 27 matching lines...) Expand all Loading... |
57 void Close(); | 57 void Close(); |
58 | 58 |
59 // Returns whether the widget is visible. | 59 // Returns whether the widget is visible. |
60 bool IsShowing(); | 60 bool IsShowing(); |
61 | 61 |
62 // AnimationDelegate implementation. | 62 // AnimationDelegate implementation. |
63 void AnimationProgressed(const Animation* animation); | 63 void AnimationProgressed(const Animation* animation); |
64 void AnimationEnded(const Animation* animation); | 64 void AnimationEnded(const Animation* animation); |
65 | 65 |
66 private: | 66 private: |
| 67 static void OnChildSizeAllocate(GtkWidget* child, |
| 68 GtkAllocation* allocation, |
| 69 SlideAnimatorGtk* slider); |
| 70 |
67 scoped_ptr<SlideAnimation> animation_; | 71 scoped_ptr<SlideAnimation> animation_; |
68 | 72 |
69 // The top level widget of the SlideAnimatorGtk. It is a GtkFixed. | 73 // The top level widget of the SlideAnimatorGtk. It is a GtkFixed. |
70 OwnedWidgetGtk widget_; | 74 OwnedWidgetGtk widget_; |
71 | 75 |
72 // The widget passed to us at construction time, and the only direct child of | 76 // The widget passed to us at construction time, and the only direct child of |
73 // |widget_|. | 77 // |widget_|. |
74 GtkWidget* child_; | 78 GtkWidget* child_; |
75 | 79 |
76 // The direction of the slide. | 80 // The direction of the slide. |
77 Direction direction_; | 81 Direction direction_; |
78 | 82 |
79 // The object to inform about certain events. It may be NULL. | 83 // The object to inform about certain events. It may be NULL. |
80 Delegate* delegate_; | 84 Delegate* delegate_; |
| 85 |
| 86 // If true, we should resize |widget_| on the next "size-allocate" event that |
| 87 // is received by |child_|. See the comment in SlideAnimatorGtk constructor. |
| 88 bool fixed_needs_resize_; |
81 }; | 89 }; |
82 | 90 |
83 #endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ | 91 #endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ |
OLD | NEW |