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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_WIDGET_WINDOW_REORDERER_H_
6 #define UI_VIEWS_WIDGET_WINDOW_REORDERER_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/aura/window_observer.h"
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
21 // tree. Windows not associated to a view are stacked above windows with an
22 // associated view. The child windows' layers are additionally reordered
23 // according to the z-order of the associated views relative to views with
25 class WindowReorderer
: public aura::WindowObserver
{
27 WindowReorderer(aura::Window
* window
, View
* root_view
);
28 ~WindowReorderer() override
;
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
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
34 // correct z-order relative to each other and does no reordering if there
35 // are no views with an associated window.
36 void ReorderChildWindows();
39 // aura::WindowObserver overrides:
40 void OnWindowAdded(aura::Window
* new_window
) override
;
41 void OnWillRemoveWindow(aura::Window
* window
) override
;
42 void OnWindowDestroying(aura::Window
* window
) override
;
44 // The window and the root view of the native widget which owns the
46 aura::Window
* parent_window_
;
49 // Reorders windows as a result of the kHostViewKey being set on a child of
51 class AssociationObserver
;
52 scoped_ptr
<AssociationObserver
> association_observer_
;
54 DISALLOW_COPY_AND_ASSIGN(WindowReorderer
);
59 #endif // UI_VIEWS_WIDGET_WINDOW_REORDERER_H_