| 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 // 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_GTK_SLIDE_ANIMATOR_GTK_H_ | 14 #ifndef CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ |
| 15 #define CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ | 15 #define CHROME_BROWSER_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 "app/animation_delegate.h" | |
| 21 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
| 22 #include "chrome/browser/gtk/owned_widget_gtk.h" | 21 #include "chrome/browser/gtk/owned_widget_gtk.h" |
| 22 #include "ui/base/animation/animation_delegate.h" |
| 23 | 23 |
| 24 namespace ui { |
| 24 class SlideAnimation; | 25 class SlideAnimation; |
| 26 } |
| 25 | 27 |
| 26 class SlideAnimatorGtk : public AnimationDelegate { | 28 class SlideAnimatorGtk : public ui::AnimationDelegate { |
| 27 public: | 29 public: |
| 28 class Delegate { | 30 class Delegate { |
| 29 public: | 31 public: |
| 30 // Called when a call to Close() finishes animating. | 32 // Called when a call to Close() finishes animating. |
| 31 virtual void Closed() = 0; | 33 virtual void Closed() = 0; |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 virtual ~Delegate() {} | 36 virtual ~Delegate() {} |
| 35 }; | 37 }; |
| 36 | 38 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Returns whether the widget is visible. | 77 // Returns whether the widget is visible. |
| 76 bool IsShowing(); | 78 bool IsShowing(); |
| 77 | 79 |
| 78 // Returns whether the widget is currently showing the close animation. | 80 // Returns whether the widget is currently showing the close animation. |
| 79 bool IsClosing(); | 81 bool IsClosing(); |
| 80 | 82 |
| 81 // Returns whether the widget is currently showing the open or close | 83 // Returns whether the widget is currently showing the open or close |
| 82 // animation. | 84 // animation. |
| 83 bool IsAnimating(); | 85 bool IsAnimating(); |
| 84 | 86 |
| 85 // AnimationDelegate implementation. | 87 // ui::AnimationDelegate implementation. |
| 86 virtual void AnimationProgressed(const Animation* animation); | 88 virtual void AnimationProgressed(const ui::Animation* animation); |
| 87 virtual void AnimationEnded(const Animation* animation); | 89 virtual void AnimationEnded(const ui::Animation* animation); |
| 88 | 90 |
| 89 // Used during testing; disable or enable animations (default is enabled). | 91 // Used during testing; disable or enable animations (default is enabled). |
| 90 static void SetAnimationsForTesting(bool enable); | 92 static void SetAnimationsForTesting(bool enable); |
| 91 | 93 |
| 92 private: | 94 private: |
| 93 static void OnChildSizeAllocate(GtkWidget* child, | 95 static void OnChildSizeAllocate(GtkWidget* child, |
| 94 GtkAllocation* allocation, | 96 GtkAllocation* allocation, |
| 95 SlideAnimatorGtk* slider); | 97 SlideAnimatorGtk* slider); |
| 96 | 98 |
| 97 scoped_ptr<SlideAnimation> animation_; | 99 scoped_ptr<ui::SlideAnimation> animation_; |
| 98 | 100 |
| 99 // The top level widget of the SlideAnimatorGtk. It is a GtkFixed. | 101 // The top level widget of the SlideAnimatorGtk. It is a GtkFixed. |
| 100 OwnedWidgetGtk widget_; | 102 OwnedWidgetGtk widget_; |
| 101 | 103 |
| 102 // The widget passed to us at construction time, and the only direct child of | 104 // The widget passed to us at construction time, and the only direct child of |
| 103 // |widget_|. | 105 // |widget_|. |
| 104 GtkWidget* child_; | 106 GtkWidget* child_; |
| 105 | 107 |
| 106 // The direction of the slide. | 108 // The direction of the slide. |
| 107 Direction direction_; | 109 Direction direction_; |
| 108 | 110 |
| 109 // The object to inform about certain events. It may be NULL. | 111 // The object to inform about certain events. It may be NULL. |
| 110 Delegate* delegate_; | 112 Delegate* delegate_; |
| 111 | 113 |
| 112 // We need to move the child widget to (0, -height), but we don't know its | 114 // We need to move the child widget to (0, -height), but we don't know its |
| 113 // height until it has been allocated. This variable will be true until the | 115 // height until it has been allocated. This variable will be true until the |
| 114 // child widget has been allocated, at which point we will move it, and then | 116 // child widget has been allocated, at which point we will move it, and then |
| 115 // set this variable to false to indicate it should not be moved again. | 117 // set this variable to false to indicate it should not be moved again. |
| 116 bool child_needs_move_; | 118 bool child_needs_move_; |
| 117 | 119 |
| 118 static bool animations_enabled_; | 120 static bool animations_enabled_; |
| 119 }; | 121 }; |
| 120 | 122 |
| 121 #endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ | 123 #endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_ |
| OLD | NEW |