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

Side by Side Diff: ui/wm/core/transient_window_manager.h

Issue 628413002: Show transient child when the transient parent is shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix check Created 6 years, 2 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
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_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_ 5 #ifndef UI_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_
6 #define UI_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_ 6 #define UI_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "ui/aura/window_observer.h" 11 #include "ui/aura/window_observer.h"
12 #include "ui/wm/wm_export.h" 12 #include "ui/wm/wm_export.h"
13 13
14 namespace wm { 14 namespace wm {
15 15
16 class TransientWindowObserver; 16 class TransientWindowObserver;
17 17
18 // TransientWindowManager manages the set of transient children for a window 18 // TransientWindowManager manages the set of transient children for a window
19 // along with the transient parent. Transient children get the following 19 // along with the transient parent. Transient children get the following
20 // behavior: 20 // behavior:
21 // . The transient parent destroys any transient children when it is 21 // . The transient parent destroys any transient children when it is
22 // destroyed. This means a transient child is destroyed if either its parent 22 // destroyed. This means a transient child is destroyed if either its parent
23 // or transient parent is destroyed. 23 // or transient parent is destroyed.
24 // . If a transient child and its transient parent share the same parent, then 24 // . If a transient child and its transient parent share the same parent, then
25 // transient children are always ordered above the transient parent. 25 // transient children are always ordered above the transient parent.
26 // . If a transient parent is hidden, it hides all transient children.
27 // For show operation, please refer to |set_parent_control_visibility(bool)|.
26 // Transient windows are typically used for popups and menus. 28 // Transient windows are typically used for popups and menus.
27 // TODO(sky): when we nuke TransientWindowClient rename this to 29 // TODO(sky): when we nuke TransientWindowClient rename this to
28 // TransientWindowController. 30 // TransientWindowController.
29 class WM_EXPORT TransientWindowManager : public aura::WindowObserver { 31 class WM_EXPORT TransientWindowManager : public aura::WindowObserver {
30 public: 32 public:
31 typedef std::vector<aura::Window*> Windows; 33 typedef std::vector<aura::Window*> Windows;
32 34
33 virtual ~TransientWindowManager(); 35 virtual ~TransientWindowManager();
34 36
35 // Returns the TransientWindowManager for |window|. This never returns NULL. 37 // Returns the TransientWindowManager for |window|. This never returns NULL.
36 static TransientWindowManager* Get(aura::Window* window); 38 static TransientWindowManager* Get(aura::Window* window);
37 39
38 // Returns the TransientWindowManager for |window| only if it already exists. 40 // Returns the TransientWindowManager for |window| only if it already exists.
39 // WARNING: this may return NULL. 41 // WARNING: this may return NULL.
40 static const TransientWindowManager* Get(const aura::Window* window); 42 static const TransientWindowManager* Get(const aura::Window* window);
41 43
42 void AddObserver(TransientWindowObserver* observer); 44 void AddObserver(TransientWindowObserver* observer);
43 void RemoveObserver(TransientWindowObserver* observer); 45 void RemoveObserver(TransientWindowObserver* observer);
44 46
45 // Adds or removes a transient child. 47 // Adds or removes a transient child.
46 void AddTransientChild(aura::Window* child); 48 void AddTransientChild(aura::Window* child);
47 void RemoveTransientChild(aura::Window* child); 49 void RemoveTransientChild(aura::Window* child);
48 50
51 // Setting true lets the transient parent show this transient
52 // child when the parent is shown. If this was shown when the
53 // transient parent is hidden, it remains hidden and gets shown
54 // when the transient parent is shown.
55 void set_parent_control_visibility(bool parent_control_visibility) {
sky 2014/10/07 15:19:14 parent_controls_visibility. Also, document the def
oshima 2014/10/07 17:41:14 Done.
56 parent_control_visibility_ = parent_control_visibility;
57 }
58
49 const Windows& transient_children() const { return transient_children_; } 59 const Windows& transient_children() const { return transient_children_; }
50 60
51 aura::Window* transient_parent() { return transient_parent_; } 61 aura::Window* transient_parent() { return transient_parent_; }
52 const aura::Window* transient_parent() const { return transient_parent_; } 62 const aura::Window* transient_parent() const { return transient_parent_; }
53 63
54 // Returns true if in the process of stacking |window_| on top of |target|. 64 // Returns true if in the process of stacking |window_| on top of |target|.
55 // That is, when the stacking order of a window changes 65 // That is, when the stacking order of a window changes
56 // (OnWindowStackingChanged()) the transients may get restacked as well. This 66 // (OnWindowStackingChanged()) the transients may get restacked as well. This
57 // function can be used to detect if TransientWindowManager is in the process 67 // function can be used to detect if TransientWindowManager is in the process
58 // of stacking a transient as the result of window stacking changing. 68 // of stacking a transient as the result of window stacking changing.
59 bool IsStackingTransient(const aura::Window* target) const; 69 bool IsStackingTransient(const aura::Window* target) const;
60 70
61 private: 71 private:
62 explicit TransientWindowManager(aura::Window* window); 72 explicit TransientWindowManager(aura::Window* window);
63 73
64 // Stacks transient descendants of this window that are its siblings just 74 // Stacks transient descendants of this window that are its siblings just
65 // above it. 75 // above it.
66 void RestackTransientDescendants(); 76 void RestackTransientDescendants();
67 77
78 // Update the window's visibility following the transient parent's
79 // visibility. See |set_parent_control_visibility(bool)| for more details.
80 void UpdateTransientChildVisibility(bool visible);
81
68 // WindowObserver: 82 // WindowObserver:
69 virtual void OnWindowParentChanged(aura::Window* window, 83 virtual void OnWindowParentChanged(aura::Window* window,
70 aura::Window* parent) OVERRIDE; 84 aura::Window* parent) OVERRIDE;
71 virtual void OnWindowVisibilityChanging(aura::Window* window, 85 virtual void OnWindowVisibilityChanging(aura::Window* window,
72 bool visible) OVERRIDE; 86 bool visible) OVERRIDE;
87 virtual void OnWindowVisibilityChanged(aura::Window* window,
88 bool visible) OVERRIDE;
73 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; 89 virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE;
74 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 90 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
75 91
76 aura::Window* window_; 92 aura::Window* window_;
77 aura::Window* transient_parent_; 93 aura::Window* transient_parent_;
78 Windows transient_children_; 94 Windows transient_children_;
79 95
80 // If non-null we're actively restacking transient as the result of a 96 // If non-null we're actively restacking transient as the result of a
81 // transient ancestor changing. 97 // transient ancestor changing.
82 aura::Window* stacking_target_; 98 aura::Window* stacking_target_;
83 99
100 bool parent_control_visibility_;
101 bool show_on_parent_visible_;
102 bool ignore_visibility_changed_event_;
103
84 ObserverList<TransientWindowObserver> observers_; 104 ObserverList<TransientWindowObserver> observers_;
85 105
86 DISALLOW_COPY_AND_ASSIGN(TransientWindowManager); 106 DISALLOW_COPY_AND_ASSIGN(TransientWindowManager);
87 }; 107 };
88 108
89 } // namespace wm 109 } // namespace wm
90 110
91 #endif // UI_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_ 111 #endif // UI_WM_CORE_TRANSIENT_WINDOW_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/wm/core/transient_window_manager.cc » ('j') | ui/wm/core/transient_window_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698