OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // NOTE: This does not handle clipping. If you are not careful, you will | 9 // NOTE: This does not handle clipping. If you are not careful, you will |
10 // wind up with visibly overlapping widgets. If you need clipping, you can | 10 // wind up with visibly overlapping widgets. If you need clipping, you can |
11 // extend the constructor to take an option to give |fixed| its own GdkWindow | 11 // extend the constructor to take an option to give |fixed| its own GdkWindow |
12 // (via gtk_fixed_set_has_window). | 12 // (via gtk_fixed_set_has_window). |
13 | 13 |
14 #ifndef CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ | 14 #ifndef CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ |
15 #define CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ | 15 #define CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ |
16 #pragma once | 16 #pragma once |
17 | 17 |
18 #include <gtk/gtk.h> | 18 #include <gtk/gtk.h> |
19 | 19 |
| 20 #include "base/compiler_specific.h" |
20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
21 #include "ui/base/animation/animation_delegate.h" | 22 #include "ui/base/animation/animation_delegate.h" |
22 #include "ui/base/gtk/owned_widget_gtk.h" | 23 #include "ui/base/gtk/owned_widget_gtk.h" |
23 | 24 |
24 namespace ui { | 25 namespace ui { |
25 class SlideAnimation; | 26 class SlideAnimation; |
26 } | 27 } |
27 | 28 |
28 class SlideAnimatorGtk : public ui::AnimationDelegate { | 29 class SlideAnimatorGtk : public ui::AnimationDelegate { |
29 public: | 30 public: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool IsShowing(); | 79 bool IsShowing(); |
79 | 80 |
80 // Returns whether the widget is currently showing the close animation. | 81 // Returns whether the widget is currently showing the close animation. |
81 bool IsClosing(); | 82 bool IsClosing(); |
82 | 83 |
83 // Returns whether the widget is currently showing the open or close | 84 // Returns whether the widget is currently showing the open or close |
84 // animation. | 85 // animation. |
85 bool IsAnimating(); | 86 bool IsAnimating(); |
86 | 87 |
87 // ui::AnimationDelegate implementation. | 88 // ui::AnimationDelegate implementation. |
88 virtual void AnimationProgressed(const ui::Animation* animation); | 89 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
89 virtual void AnimationEnded(const ui::Animation* animation); | 90 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
90 | 91 |
91 // Used during testing; disable or enable animations (default is enabled). | 92 // Used during testing; disable or enable animations (default is enabled). |
92 static void SetAnimationsForTesting(bool enable); | 93 static void SetAnimationsForTesting(bool enable); |
93 | 94 |
94 private: | 95 private: |
95 static void OnChildSizeAllocate(GtkWidget* child, | 96 static void OnChildSizeAllocate(GtkWidget* child, |
96 GtkAllocation* allocation, | 97 GtkAllocation* allocation, |
97 SlideAnimatorGtk* slider); | 98 SlideAnimatorGtk* slider); |
98 | 99 |
99 scoped_ptr<ui::SlideAnimation> animation_; | 100 scoped_ptr<ui::SlideAnimation> animation_; |
(...skipping 14 matching lines...) Expand all Loading... |
114 // We need to move the child widget to (0, -height), but we don't know its | 115 // We need to move the child widget to (0, -height), but we don't know its |
115 // height until it has been allocated. This variable will be true until the | 116 // height until it has been allocated. This variable will be true until the |
116 // child widget has been allocated, at which point we will move it, and then | 117 // child widget has been allocated, at which point we will move it, and then |
117 // set this variable to false to indicate it should not be moved again. | 118 // set this variable to false to indicate it should not be moved again. |
118 bool child_needs_move_; | 119 bool child_needs_move_; |
119 | 120 |
120 static bool animations_enabled_; | 121 static bool animations_enabled_; |
121 }; | 122 }; |
122 | 123 |
123 #endif // CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ | 124 #endif // CHROME_BROWSER_UI_GTK_SLIDE_ANIMATOR_GTK_H_ |
OLD | NEW |