OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_AURA_SHELL_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
| 6 #define UI_AURA_SHELL_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/aura/layout_manager.h" |
| 15 #include "ui/aura/window_observer.h" |
| 16 #include "ui/aura_shell/aura_shell_export.h" |
| 17 #include "ui/aura_shell/modality_event_filter_delegate.h" |
| 18 #include "ui/gfx/compositor/layer_animation_observer.h" |
| 19 |
| 20 namespace aura { |
| 21 class Window; |
| 22 class EventFilter; |
| 23 } |
| 24 namespace gfx { |
| 25 class Rect; |
| 26 } |
| 27 namespace views { |
| 28 class Widget; |
| 29 } |
| 30 |
| 31 namespace aura_shell { |
| 32 namespace internal { |
| 33 |
| 34 // LayoutManager for the modal window container. |
| 35 class AURA_SHELL_EXPORT ModalContainerLayoutManager |
| 36 : public aura::LayoutManager, |
| 37 public aura::WindowObserver, |
| 38 public ui::LayerAnimationObserver, |
| 39 public ModalityEventFilterDelegate { |
| 40 public: |
| 41 explicit ModalContainerLayoutManager(aura::Window* container); |
| 42 virtual ~ModalContainerLayoutManager(); |
| 43 |
| 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; |
| 52 |
| 53 // Overridden from aura::WindowObserver: |
| 54 virtual void OnPropertyChanged(aura::Window* window, |
| 55 const char* key, |
| 56 void* old) OVERRIDE; |
| 57 |
| 58 // Overridden from ui::LayerAnimationObserver: |
| 59 virtual void OnLayerAnimationEnded( |
| 60 const ui::LayerAnimationSequence* sequence) OVERRIDE; |
| 61 virtual void OnLayerAnimationAborted( |
| 62 const ui::LayerAnimationSequence* sequence) OVERRIDE; |
| 63 virtual void OnLayerAnimationScheduled( |
| 64 const ui::LayerAnimationSequence* sequence) OVERRIDE; |
| 65 |
| 66 // Overridden from ModalityEventFilterDelegate: |
| 67 virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE; |
| 68 |
| 69 private: |
| 70 void AddModalWindow(aura::Window* window); |
| 71 void RemoveModalWindow(aura::Window* window); |
| 72 |
| 73 void CreateModalScreen(); |
| 74 void DestroyModalScreen(); |
| 75 void HideModalScreen(); |
| 76 |
| 77 aura::Window* modal_window() { |
| 78 return !modal_windows_.empty() ? modal_windows_.back() : NULL; |
| 79 } |
| 80 |
| 81 // The container that owns the layout manager. |
| 82 aura::Window* container_; |
| 83 |
| 84 // A "screen" widget that dims the windows behind the modal window(s) being |
| 85 // shown in |container_|. |
| 86 views::Widget* modal_screen_; |
| 87 |
| 88 // A stack of modal windows. Only the topmost can receive events. |
| 89 std::vector<aura::Window*> modal_windows_; |
| 90 |
| 91 // An event filter that enforces the modality of the topmost window in |
| 92 // |modal_windows_|. The event filter is attached when a modal window is |
| 93 // added, and removed when the last is closed. |
| 94 scoped_ptr<aura::EventFilter> modality_filter_; |
| 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(ModalContainerLayoutManager); |
| 97 }; |
| 98 |
| 99 } // namespace internal |
| 100 } // namespace aura_shell |
| 101 |
| 102 #endif // UI_AURA_SHELL_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
OLD | NEW |