OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | |
6 #define UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "ui/aura/window_observer.h" | |
11 #include "ui/views/views_export.h" | |
12 | |
13 namespace views { | |
14 namespace corewm { | |
15 | |
16 // Convenience functions that get the TransientWindowManager for the window and | |
17 // redirect appropriately. These are preferable to calling functions on | |
18 // TransientWindowManager as they handle the appropriate NULL checks. | |
19 VIEWS_EXPORT aura::Window* GetTransientParent(aura::Window* window); | |
Ben Goodger (Google)
2013/12/18 00:32:38
maybe move these functions to window_util.cc/h in
sky
2014/01/06 18:42:48
Done.
| |
20 VIEWS_EXPORT const aura::Window* GetTransientParent(const aura::Window* window); | |
21 VIEWS_EXPORT const std::vector<aura::Window*>& GetTransientChildren( | |
22 const aura::Window* window); | |
23 VIEWS_EXPORT void AddTransientChild(aura::Window* parent, aura::Window* child); | |
24 VIEWS_EXPORT void RemoveTransientChild(aura::Window* parent, | |
25 aura::Window* child); | |
26 | |
27 // Returns true if |window| has |ancestor| as a transient ancestor. A transient | |
28 // ancestor is found by following the transient parent chain of the window. | |
29 VIEWS_EXPORT bool HasTransientAncestor(const aura::Window* window, | |
30 const aura::Window* ancestor); | |
31 | |
32 // TransientWindowManager manages the set of transient children for a window | |
33 // along with the transient parent. Transient children get the following | |
34 // behavior: | |
35 // . The transient parent destroys any transient children when it is | |
36 // destroyed. This means a transient child is destroyed if either its parent | |
37 // or transient parent is destroyed. | |
38 // . If a transient child and its transient parent share the same parent, then | |
39 // transient children are always ordered above the transient parent. | |
40 // Transient windows are typically used for popups and menus. | |
41 class VIEWS_EXPORT TransientWindowManager : public aura::WindowObserver { | |
Ben Goodger (Google)
2013/12/18 00:32:38
soft preference for this to be TransientWindowCont
sky
2014/01/06 18:42:48
I ended up needing aura/client/transient_window_cl
| |
42 public: | |
43 typedef std::vector<aura::Window*> Windows; | |
44 | |
45 virtual ~TransientWindowManager(); | |
46 | |
47 // Returns the TransientWindowManager for |window|. This never returns NULL. | |
48 static TransientWindowManager* Get(aura::Window* window); | |
49 | |
50 // Returns the TransientWindowManager for |window| only if it already exists. | |
51 // WARNING: this may return NULL. | |
52 static const TransientWindowManager* Get(const aura::Window* window); | |
53 | |
54 // Adds or removes a transient child. | |
55 void AddTransientChild(aura::Window* child); | |
56 void RemoveTransientChild(aura::Window* child); | |
57 | |
58 const Windows& transient_children() const { return transient_children_; } | |
59 | |
60 aura::Window* transient_parent() { return transient_parent_; } | |
61 const aura::Window* transient_parent() const { return transient_parent_; } | |
62 | |
63 // Returns true if in the process of stacking |child| on top of |target|. That | |
64 // is, when the stacking order of a window changes (OnWindowStackingChanged()) | |
65 // the transients may get restacked as well. This function can be used to | |
66 // detect if TransientWindowManager is in the process of stacking a transient | |
67 // as the result of window stacking changing. | |
68 bool IsStackingTransient(const aura::Window* child, | |
69 const aura::Window* target) const; | |
70 | |
71 // WindowObserver: | |
Ben Goodger (Google)
2013/12/18 00:32:38
private
| |
72 virtual void OnWindowVisibilityChanging(aura::Window* window, | |
73 bool visible) OVERRIDE; | |
74 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; | |
75 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | |
76 | |
77 private: | |
78 // Used to identify when a stacking change needs to restack transients. | |
79 struct StackingPair { | |
80 StackingPair(const aura::Window* child, const aura::Window* target) | |
81 : child(child), | |
82 target(target) {} | |
83 | |
84 // The window being moved. | |
85 const aura::Window* child; | |
86 | |
87 // |child| is being stacked on top of this. | |
88 const aura::Window* target; | |
89 }; | |
90 | |
91 explicit TransientWindowManager(aura::Window* window); | |
92 | |
93 // Invoked whne |child|'s stacking order changes. | |
94 void OnChildStackingChanged(aura::Window* child); | |
95 | |
96 aura::Window* window_; | |
97 aura::Window* transient_parent_; | |
98 Windows transient_children_; | |
99 | |
100 // If non-null we're actively restacking transient as the result of a | |
101 // transient ancestor changing. This is a pointer to a value on the stack. | |
102 StackingPair* stacking_pair_; | |
103 | |
104 DISALLOW_COPY_AND_ASSIGN(TransientWindowManager); | |
105 }; | |
106 | |
107 } // namespace corewm | |
108 } // namespace views | |
109 | |
110 #endif // UI_VIEWS_COREWM_TRANSIENT_WINDOW_MANAGER_H_ | |
OLD | NEW |