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_WM_PANEL_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_PANEL_LAYOUT_MANAGER_H_ |
6 #define ASH_WM_PANEL_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_PANEL_LAYOUT_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "ash/launcher/launcher_icon_observer.h" | 12 #include "ash/launcher/launcher_icon_observer.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
| 16 #include "ui/aura/window_observer.h" |
16 | 17 |
17 namespace aura { | 18 namespace aura { |
18 class Window; | 19 class Window; |
19 } | 20 } |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 class Rect; | 23 class Rect; |
23 } | 24 } |
24 | 25 |
25 namespace ash { | 26 namespace ash { |
26 class Launcher; | 27 class Launcher; |
27 | 28 |
28 namespace internal { | 29 namespace internal { |
29 | 30 |
30 // PanelLayoutManager is responsible for organizing panels within the | 31 // PanelLayoutManager is responsible for organizing panels within the |
31 // workspace. It is associated with a specific container window (i.e. | 32 // workspace. It is associated with a specific container window (i.e. |
32 // kShellWindowId_PanelContainer) and controls the layout of any windows | 33 // kShellWindowId_PanelContainer) and controls the layout of any windows |
33 // added to that container. | 34 // added to that container. |
34 // | 35 // |
35 // The constructor takes a |panel_container| argument which is expected to set | 36 // The constructor takes a |panel_container| argument which is expected to set |
36 // its layout manager to this instance, e.g.: | 37 // its layout manager to this instance, e.g.: |
37 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); | 38 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); |
38 | 39 |
39 class ASH_EXPORT PanelLayoutManager : public aura::LayoutManager, | 40 class ASH_EXPORT PanelLayoutManager : public aura::LayoutManager, |
40 public ash::LauncherIconObserver { | 41 public ash::LauncherIconObserver, |
| 42 public aura::WindowObserver { |
41 public: | 43 public: |
42 explicit PanelLayoutManager(aura::Window* panel_container); | 44 explicit PanelLayoutManager(aura::Window* panel_container); |
43 virtual ~PanelLayoutManager(); | 45 virtual ~PanelLayoutManager(); |
44 | 46 |
45 void StartDragging(aura::Window* panel); | 47 void StartDragging(aura::Window* panel); |
46 void FinishDragging(); | 48 void FinishDragging(); |
47 | 49 |
48 void ToggleMinimize(aura::Window* panel); | 50 void ToggleMinimize(aura::Window* panel); |
49 | 51 |
50 void SetLauncher(ash::Launcher* launcher); | 52 void SetLauncher(ash::Launcher* launcher); |
51 | 53 |
52 // Overridden from aura::LayoutManager: | 54 // Overridden from aura::LayoutManager: |
53 virtual void OnWindowResized() OVERRIDE; | 55 virtual void OnWindowResized() OVERRIDE; |
54 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; | 56 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
55 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; | 57 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; |
56 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; | 58 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; |
57 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 59 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
58 bool visibile) OVERRIDE; | 60 bool visibile) OVERRIDE; |
59 virtual void SetChildBounds(aura::Window* child, | 61 virtual void SetChildBounds(aura::Window* child, |
60 const gfx::Rect& requested_bounds) OVERRIDE; | 62 const gfx::Rect& requested_bounds) OVERRIDE; |
61 | 63 |
62 // Overriden from ash::LauncherIconObserver | 64 // Overridden from ash::LauncherIconObserver |
63 virtual void OnLauncherIconPositionsChanged() OVERRIDE; | 65 virtual void OnLauncherIconPositionsChanged() OVERRIDE; |
64 | 66 |
| 67 // Overridden from aura::WindowObserver |
| 68 virtual void OnWindowPropertyChanged( |
| 69 aura::Window* window, const void* key, intptr_t old) OVERRIDE; |
| 70 |
65 private: | 71 private: |
66 typedef std::list<aura::Window*> PanelList; | 72 typedef std::list<aura::Window*> PanelList; |
67 | 73 |
68 // Called whenever the panel layout might change. | 74 // Called whenever the panel layout might change. |
69 void Relayout(); | 75 void Relayout(); |
70 | 76 |
| 77 // Called whenever the panel stacking order needs to be updated (e.g. focus |
| 78 // changes or a panel is moved). |
| 79 void UpdateStacking(aura::Window* active_window); |
| 80 |
71 // Parent window associated with this layout manager. | 81 // Parent window associated with this layout manager. |
72 aura::Window* panel_container_; | 82 aura::Window* panel_container_; |
73 // Protect against recursive calls to Relayout(). | 83 // Protect against recursive calls to Relayout(). |
74 bool in_layout_; | 84 bool in_layout_; |
75 // Ordered list of unowned pointers to panel windows. | 85 // Ordered list of unowned pointers to panel windows. |
76 PanelList panel_windows_; | 86 PanelList panel_windows_; |
77 | 87 // The panel being dragged. |
78 aura::Window* dragged_panel_; | 88 aura::Window* dragged_panel_; |
79 | 89 // The launcher we are observing for launcher icon changes. |
80 Launcher* launcher_; | 90 Launcher* launcher_; |
| 91 // The last active panel. Used to maintain stacking even if no panels are |
| 92 // currently focused. |
| 93 aura::Window* last_active_panel_; |
81 | 94 |
82 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); | 95 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); |
83 }; | 96 }; |
84 | 97 |
85 } // namespace internal | 98 } // namespace internal |
86 } // namespace ash | 99 } // namespace ash |
87 | 100 |
88 #endif // ASH_WM_PANEL_LAYOUT_MANAGER_H_ | 101 #endif // ASH_WM_PANEL_LAYOUT_MANAGER_H_ |
OLD | NEW |