| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WALLPAPER_WALLPAPER_WIDGET_CONTROLLER_H_ | |
| 6 #define ASH_WALLPAPER_WALLPAPER_WIDGET_CONTROLLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "ash/common/wm_window_observer.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "ui/views/widget/widget_observer.h" | |
| 14 | |
| 15 namespace aura { | |
| 16 class Window; | |
| 17 } | |
| 18 | |
| 19 namespace ash { | |
| 20 class RootWindowController; | |
| 21 | |
| 22 // This class implements a widget-based wallpaper. | |
| 23 // WallpaperWidgetController is owned by RootWindowController. | |
| 24 // When the animation completes the old WallpaperWidgetController is | |
| 25 // destroyed. Exported for tests. | |
| 26 class ASH_EXPORT WallpaperWidgetController : public views::WidgetObserver, | |
| 27 public WmWindowObserver { | |
| 28 public: | |
| 29 explicit WallpaperWidgetController(views::Widget* widget); | |
| 30 ~WallpaperWidgetController() override; | |
| 31 | |
| 32 // Overridden from views::WidgetObserver. | |
| 33 void OnWidgetDestroying(views::Widget* widget) override; | |
| 34 | |
| 35 // Set bounds for the widget that draws the wallpaper. | |
| 36 void SetBounds(const gfx::Rect& bounds); | |
| 37 | |
| 38 // Move the wallpaper for |root_window| to the specified |container|. | |
| 39 // The lock screen moves the wallpaper container to hides the user's windows. | |
| 40 // Returns true if there was something to reparent. | |
| 41 bool Reparent(aura::Window* root_window, int container); | |
| 42 | |
| 43 // Starts wallpaper fade in animation. |root_window_controller| is | |
| 44 // the root window where the animation will happen. (This is | |
| 45 // necessary this as |layer_| doesn't have access to the root window). | |
| 46 void StartAnimating(RootWindowController* root_window_controller); | |
| 47 | |
| 48 views::Widget* widget() { return widget_; } | |
| 49 | |
| 50 private: | |
| 51 void RemoveObservers(); | |
| 52 | |
| 53 // WmWindowObserver: | |
| 54 void OnWindowBoundsChanged(WmWindow* window, | |
| 55 const gfx::Rect& old_bounds, | |
| 56 const gfx::Rect& new_bounds) override; | |
| 57 | |
| 58 views::Widget* widget_; | |
| 59 | |
| 60 // Parent of |widget_|. | |
| 61 WmWindow* widget_parent_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(WallpaperWidgetController); | |
| 64 }; | |
| 65 | |
| 66 // This class wraps a WallpaperWidgetController pointer. It is owned | |
| 67 // by RootWindowController. The instance of WallpaperWidgetController is | |
| 68 // moved to this RootWindowController when the animation completes. | |
| 69 // Exported for tests. | |
| 70 class ASH_EXPORT AnimatingWallpaperWidgetController { | |
| 71 public: | |
| 72 explicit AnimatingWallpaperWidgetController( | |
| 73 WallpaperWidgetController* component); | |
| 74 ~AnimatingWallpaperWidgetController(); | |
| 75 | |
| 76 // Stops animation and makes sure OnImplicitAnimationsCompleted() is called if | |
| 77 // current animation is not finished yet. | |
| 78 // Note we have to make sure this function is called before we set | |
| 79 // AnimatingWallpaperWidgetController to a new controller. If it is not | |
| 80 // called, the animating widget/layer is closed immediately and the new one is | |
| 81 // animating from the widget/layer before animation. For instance, if a user | |
| 82 // quickly switches between red, green and blue wallpapers. The green | |
| 83 // wallpaper will first fade in from red wallpaper. And in the middle of the | |
| 84 // animation, blue wallpaper also wants to fade in. If the green wallpaper | |
| 85 // animation does not finish immediately, the green wallpaper widget will be | |
| 86 // removed and the red widget will show again. As a result, the blue wallpaper | |
| 87 // fades in from red wallpaper. This is a bad user experience. See bug | |
| 88 // http://crbug.com/156542 for more details. | |
| 89 void StopAnimating(); | |
| 90 | |
| 91 // Gets the wrapped WallpaperWidgetController pointer. Caller should | |
| 92 // take ownership of the pointer if |pass_ownership| is true. | |
| 93 WallpaperWidgetController* GetController(bool pass_ownership); | |
| 94 | |
| 95 private: | |
| 96 std::unique_ptr<WallpaperWidgetController> controller_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(AnimatingWallpaperWidgetController); | |
| 99 }; | |
| 100 | |
| 101 } // namespace ash | |
| 102 | |
| 103 #endif // ASH_WALLPAPER_WALLPAPER_WIDGET_CONTROLLER_H_ | |
| OLD | NEW |