1 // Copyright (c) 2012 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 ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
11 #include "ash/wm/system_modal_container_event_filter_delegate.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/window_observer.h"
17 #include "ash/ash_export.h"
18 #include "ui/gfx/compositor/layer_animation_observer.h"
34 // LayoutManager for the modal window container.
35 class ASH_EXPORT SystemModalContainerLayoutManager
36 : public aura::LayoutManager
,
37 public aura::WindowObserver
,
38 public ui::ImplicitAnimationObserver
,
39 public SystemModalContainerEventFilterDelegate
{
41 explicit SystemModalContainerLayoutManager(aura::Window
* container
);
42 virtual ~SystemModalContainerLayoutManager();
44 // Overridden from aura::LayoutManager:
45 virtual void OnWindowResized() OVERRIDE
;
46 virtual void OnWindowAddedToLayout(aura::Window
* child
) OVERRIDE
;
47 virtual void OnWillRemoveWindowFromLayout(aura::Window
* child
) OVERRIDE
;
48 virtual void OnChildWindowVisibilityChanged(aura::Window
* child
,
49 bool visibile
) OVERRIDE
;
50 virtual void SetChildBounds(aura::Window
* child
,
51 const gfx::Rect
& requested_bounds
) OVERRIDE
;
53 // Overridden from aura::WindowObserver:
54 virtual void OnWindowPropertyChanged(aura::Window
* window
,
56 intptr_t old
) OVERRIDE
;
57 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
59 // Overridden from ui::ImplicitAnimationObserver:
60 virtual void OnImplicitAnimationsCompleted() OVERRIDE
;
62 // Overridden from SystemModalContainerEventFilterDelegate:
63 virtual bool CanWindowReceiveEvents(aura::Window
* window
) OVERRIDE
;
66 void AddModalWindow(aura::Window
* window
);
67 void RemoveModalWindow(aura::Window
* window
);
69 void CreateModalScreen();
70 void DestroyModalScreen();
71 void HideModalScreen();
73 aura::Window
* modal_window() {
74 return !modal_windows_
.empty() ? modal_windows_
.back() : NULL
;
77 // The container that owns the layout manager.
78 aura::Window
* container_
;
80 // A "screen" widget that dims the windows behind the modal window(s) being
81 // shown in |container_|.
82 views::Widget
* modal_screen_
;
84 // A stack of modal windows. Only the topmost can receive events.
85 std::vector
<aura::Window
*> modal_windows_
;
87 // An event filter that enforces the modality of the topmost window in
88 // |modal_windows_|. The event filter is attached when a modal window is
89 // added, and removed when the last is closed.
90 scoped_ptr
<aura::EventFilter
> modality_filter_
;
92 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager
);
95 } // namespace internal
98 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_