OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | 5 #ifndef UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ |
6 #define UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | 6 #define UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/observer_list.h" |
10 #include "ui/aura/window_observer.h" | 11 #include "ui/aura/window_observer.h" |
11 #include "ui/views/views_export.h" | 12 #include "ui/views/views_export.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 namespace corewm { | 15 namespace corewm { |
15 | 16 |
| 17 class TransientWindowObserver; |
| 18 |
16 // TransientWindowManager manages the set of transient children for a window | 19 // TransientWindowManager manages the set of transient children for a window |
17 // along with the transient parent. Transient children get the following | 20 // along with the transient parent. Transient children get the following |
18 // behavior: | 21 // behavior: |
19 // . The transient parent destroys any transient children when it is | 22 // . The transient parent destroys any transient children when it is |
20 // destroyed. This means a transient child is destroyed if either its parent | 23 // destroyed. This means a transient child is destroyed if either its parent |
21 // or transient parent is destroyed. | 24 // or transient parent is destroyed. |
22 // . If a transient child and its transient parent share the same parent, then | 25 // . If a transient child and its transient parent share the same parent, then |
23 // transient children are always ordered above the transient parent. | 26 // transient children are always ordered above the transient parent. |
24 // Transient windows are typically used for popups and menus. | 27 // Transient windows are typically used for popups and menus. |
25 // TODO(sky): when we nuke TransientWindowClient rename this to | 28 // TODO(sky): when we nuke TransientWindowClient rename this to |
26 // TransientWindowController. | 29 // TransientWindowController. |
27 class VIEWS_EXPORT TransientWindowManager : public aura::WindowObserver { | 30 class VIEWS_EXPORT TransientWindowManager : public aura::WindowObserver { |
28 public: | 31 public: |
29 typedef std::vector<aura::Window*> Windows; | 32 typedef std::vector<aura::Window*> Windows; |
30 | 33 |
31 virtual ~TransientWindowManager(); | 34 virtual ~TransientWindowManager(); |
32 | 35 |
33 // Returns the TransientWindowManager for |window|. This never returns NULL. | 36 // Returns the TransientWindowManager for |window|. This never returns NULL. |
34 static TransientWindowManager* Get(aura::Window* window); | 37 static TransientWindowManager* Get(aura::Window* window); |
35 | 38 |
36 // Returns the TransientWindowManager for |window| only if it already exists. | 39 // Returns the TransientWindowManager for |window| only if it already exists. |
37 // WARNING: this may return NULL. | 40 // WARNING: this may return NULL. |
38 static const TransientWindowManager* Get(const aura::Window* window); | 41 static const TransientWindowManager* Get(const aura::Window* window); |
39 | 42 |
| 43 void AddObserver(TransientWindowObserver* observer); |
| 44 void RemoveObserver(TransientWindowObserver* observer); |
| 45 |
40 // Adds or removes a transient child. | 46 // Adds or removes a transient child. |
41 void AddTransientChild(aura::Window* child); | 47 void AddTransientChild(aura::Window* child); |
42 void RemoveTransientChild(aura::Window* child); | 48 void RemoveTransientChild(aura::Window* child); |
43 | 49 |
44 const Windows& transient_children() const { return transient_children_; } | 50 const Windows& transient_children() const { return transient_children_; } |
45 | 51 |
46 aura::Window* transient_parent() { return transient_parent_; } | 52 aura::Window* transient_parent() { return transient_parent_; } |
47 const aura::Window* transient_parent() const { return transient_parent_; } | 53 const aura::Window* transient_parent() const { return transient_parent_; } |
48 | 54 |
49 // Returns true if in the process of stacking |child| on top of |target|. That | 55 // Returns true if in the process of stacking |child| on top of |target|. That |
(...skipping 30 matching lines...) Expand all Loading... |
80 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 86 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
81 | 87 |
82 aura::Window* window_; | 88 aura::Window* window_; |
83 aura::Window* transient_parent_; | 89 aura::Window* transient_parent_; |
84 Windows transient_children_; | 90 Windows transient_children_; |
85 | 91 |
86 // If non-null we're actively restacking transient as the result of a | 92 // If non-null we're actively restacking transient as the result of a |
87 // transient ancestor changing. This is a pointer to a value on the stack. | 93 // transient ancestor changing. This is a pointer to a value on the stack. |
88 StackingPair* stacking_pair_; | 94 StackingPair* stacking_pair_; |
89 | 95 |
| 96 ObserverList<TransientWindowObserver> observers_; |
| 97 |
90 DISALLOW_COPY_AND_ASSIGN(TransientWindowManager); | 98 DISALLOW_COPY_AND_ASSIGN(TransientWindowManager); |
91 }; | 99 }; |
92 | 100 |
93 } // namespace corewm | 101 } // namespace corewm |
94 } // namespace views | 102 } // namespace views |
95 | 103 |
96 #endif // UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | 104 #endif // UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ |
OLD | NEW |