OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_WIDGET_WINDOW_REORDERER_H_ | 5 #ifndef UI_VIEWS_WIDGET_WINDOW_REORDERER_H_ |
6 #define UI_VIEWS_WIDGET_WINDOW_REORDERER_H_ | 6 #define UI_VIEWS_WIDGET_WINDOW_REORDERER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/aura/window_observer.h" | 10 #include "ui/aura/window_observer.h" |
11 | 11 |
12 namespace aura { | 12 namespace aura { |
13 class Window; | 13 class Window; |
14 } | 14 } |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 class View; | 17 class View; |
18 | 18 |
19 // Class which reorders the widget's child windows which have an associated view | 19 // Class which reorders the widget's child windows which have an associated view |
20 // in the widget's view tree according the z-order of the views in the view | 20 // in the widget's view tree according the z-order of the views in the view |
21 // tree. Windows not associated to a view are stacked above windows with an | 21 // tree. Windows not associated to a view are stacked above windows with an |
22 // associated view. The child windows' layers are additionally reordered | 22 // associated view. The child windows' layers are additionally reordered |
23 // according to the z-order of the associated views relative to views with | 23 // according to the z-order of the associated views relative to views with |
24 // layers. | 24 // layers. |
25 class WindowReorderer : public aura::WindowObserver { | 25 class WindowReorderer : public aura::WindowObserver { |
26 public: | 26 public: |
27 WindowReorderer(aura::Window* window, View* root_view); | 27 WindowReorderer(aura::Window* window, View* root_view); |
28 virtual ~WindowReorderer(); | 28 ~WindowReorderer() override; |
29 | 29 |
30 // Explicitly reorder the children of |window_| (and their layers). This | 30 // Explicitly reorder the children of |window_| (and their layers). This |
31 // method should be called when the position of a view with an associated | 31 // method should be called when the position of a view with an associated |
32 // window changes in the view hierarchy. This method assumes that the | 32 // window changes in the view hierarchy. This method assumes that the |
33 // child layers of |window_| which are owned by views are already in the | 33 // child layers of |window_| which are owned by views are already in the |
34 // correct z-order relative to each other and does no reordering if there | 34 // correct z-order relative to each other and does no reordering if there |
35 // are no views with an associated window. | 35 // are no views with an associated window. |
36 void ReorderChildWindows(); | 36 void ReorderChildWindows(); |
37 | 37 |
38 private: | 38 private: |
39 // aura::WindowObserver overrides: | 39 // aura::WindowObserver overrides: |
40 virtual void OnWindowAdded(aura::Window* new_window) override; | 40 void OnWindowAdded(aura::Window* new_window) override; |
41 virtual void OnWillRemoveWindow(aura::Window* window) override; | 41 void OnWillRemoveWindow(aura::Window* window) override; |
42 virtual void OnWindowDestroying(aura::Window* window) override; | 42 void OnWindowDestroying(aura::Window* window) override; |
43 | 43 |
44 // The window and the root view of the native widget which owns the | 44 // The window and the root view of the native widget which owns the |
45 // WindowReorderer. | 45 // WindowReorderer. |
46 aura::Window* parent_window_; | 46 aura::Window* parent_window_; |
47 View* root_view_; | 47 View* root_view_; |
48 | 48 |
49 // Reorders windows as a result of the kHostViewKey being set on a child of | 49 // Reorders windows as a result of the kHostViewKey being set on a child of |
50 // |parent_window_|. | 50 // |parent_window_|. |
51 class AssociationObserver; | 51 class AssociationObserver; |
52 scoped_ptr<AssociationObserver> association_observer_; | 52 scoped_ptr<AssociationObserver> association_observer_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(WindowReorderer); | 54 DISALLOW_COPY_AND_ASSIGN(WindowReorderer); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace views | 57 } // namespace views |
58 | 58 |
59 #endif // UI_VIEWS_WIDGET_WINDOW_REORDERER_H_ | 59 #endif // UI_VIEWS_WIDGET_WINDOW_REORDERER_H_ |
OLD | NEW |