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

Side by Side Diff: ash/common/wallpaper/wallpaper_widget_controller.h

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

Powered by Google App Engine
This is Rietveld 408576698