OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ | 5 #ifndef ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ |
6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ | 6 #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/common/wm/wm_window_observer.h" | 11 #include "ash/common/wm_window_observer.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "ui/views/widget/widget_observer.h" | 13 #include "ui/views/widget/widget_observer.h" |
14 | 14 |
15 namespace aura { | 15 namespace aura { |
16 class Window; | 16 class Window; |
17 } | 17 } |
18 | 18 |
19 namespace ash { | 19 namespace ash { |
20 class RootWindowController; | 20 class RootWindowController; |
21 | 21 |
22 // This class implements a widget-based wallpaper. | 22 // This class implements a widget-based wallpaper. |
23 // DesktopBackgroundWidgetController is owned by RootWindowController. | 23 // DesktopBackgroundWidgetController is owned by RootWindowController. |
24 // When the animation completes the old DesktopBackgroundWidgetController is | 24 // When the animation completes the old DesktopBackgroundWidgetController is |
25 // destroyed. Exported for tests. | 25 // destroyed. Exported for tests. |
26 class ASH_EXPORT DesktopBackgroundWidgetController | 26 class ASH_EXPORT DesktopBackgroundWidgetController |
27 : public views::WidgetObserver, | 27 : public views::WidgetObserver, |
28 public wm::WmWindowObserver { | 28 public WmWindowObserver { |
29 public: | 29 public: |
30 // Create | 30 // Create |
31 explicit DesktopBackgroundWidgetController(views::Widget* widget); | 31 explicit DesktopBackgroundWidgetController(views::Widget* widget); |
32 | 32 |
33 ~DesktopBackgroundWidgetController() override; | 33 ~DesktopBackgroundWidgetController() override; |
34 | 34 |
35 // Overridden from views::WidgetObserver. | 35 // Overridden from views::WidgetObserver. |
36 void OnWidgetDestroying(views::Widget* widget) override; | 36 void OnWidgetDestroying(views::Widget* widget) override; |
37 | 37 |
38 // Set bounds of component that draws background. | 38 // Set bounds of component that draws background. |
39 void SetBounds(const gfx::Rect& bounds); | 39 void SetBounds(const gfx::Rect& bounds); |
40 | 40 |
41 // Move component from |src_container| in |root_window| to |dest_container|. | 41 // Move component from |src_container| in |root_window| to |dest_container|. |
42 // It is required for lock screen, when we need to move background so that | 42 // It is required for lock screen, when we need to move background so that |
43 // it hides user's windows. Returns true if there was something to reparent. | 43 // it hides user's windows. Returns true if there was something to reparent. |
44 bool Reparent(aura::Window* root_window, | 44 bool Reparent(aura::Window* root_window, |
45 int src_container, | 45 int src_container, |
46 int dest_container); | 46 int dest_container); |
47 | 47 |
48 // Starts wallpaper fade in animation. |root_window_controller| is | 48 // Starts wallpaper fade in animation. |root_window_controller| is |
49 // the root window where the animation will happen. (This is | 49 // the root window where the animation will happen. (This is |
50 // necessary this as |layer_| doesn't have access to the root window). | 50 // necessary this as |layer_| doesn't have access to the root window). |
51 void StartAnimating(RootWindowController* root_window_controller); | 51 void StartAnimating(RootWindowController* root_window_controller); |
52 | 52 |
53 views::Widget* widget() { return widget_; } | 53 views::Widget* widget() { return widget_; } |
54 | 54 |
55 private: | 55 private: |
56 void RemoveObservers(); | 56 void RemoveObservers(); |
57 | 57 |
58 // wm::WmWindowObserver: | 58 // WmWindowObserver: |
59 void OnWindowBoundsChanged(wm::WmWindow* window, | 59 void OnWindowBoundsChanged(WmWindow* window, |
60 const gfx::Rect& old_bounds, | 60 const gfx::Rect& old_bounds, |
61 const gfx::Rect& new_bounds) override; | 61 const gfx::Rect& new_bounds) override; |
62 | 62 |
63 views::Widget* widget_; | 63 views::Widget* widget_; |
64 | 64 |
65 // Parent of |widget_|. | 65 // Parent of |widget_|. |
66 wm::WmWindow* widget_parent_; | 66 WmWindow* widget_parent_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController); | 68 DISALLOW_COPY_AND_ASSIGN(DesktopBackgroundWidgetController); |
69 }; | 69 }; |
70 | 70 |
71 // This class wraps a DesktopBackgroundWidgetController pointer. It is owned | 71 // This class wraps a DesktopBackgroundWidgetController pointer. It is owned |
72 // by RootWindowController. The instance of DesktopBackgroundWidgetController is | 72 // by RootWindowController. The instance of DesktopBackgroundWidgetController is |
73 // moved to this RootWindowController when the animation completes. | 73 // moved to this RootWindowController when the animation completes. |
74 // Exported for tests. | 74 // Exported for tests. |
75 class ASH_EXPORT AnimatingDesktopController { | 75 class ASH_EXPORT AnimatingDesktopController { |
76 public: | 76 public: |
(...skipping 22 matching lines...) Expand all Loading... |
99 | 99 |
100 private: | 100 private: |
101 std::unique_ptr<DesktopBackgroundWidgetController> controller_; | 101 std::unique_ptr<DesktopBackgroundWidgetController> controller_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(AnimatingDesktopController); | 103 DISALLOW_COPY_AND_ASSIGN(AnimatingDesktopController); |
104 }; | 104 }; |
105 | 105 |
106 } // namespace ash | 106 } // namespace ash |
107 | 107 |
108 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ | 108 #endif // ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_WIDGET_CONTROLLER_H_ |
OLD | NEW |