Added llvm into exceptions as we can't add README.chromium into 3rd party repository
[chromium-blink-merge.git] / ash / wm / system_modal_container_layout_manager.h
blob59c0eac89223187f13374182ae1e061c1b8eb4af
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_
8 #include <vector>
10 #include "ash/ash_export.h"
11 #include "ash/snap_to_pixel_layout_manager.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/keyboard/keyboard_controller_observer.h"
18 namespace aura {
19 class Window;
20 class EventFilter;
22 namespace gfx {
23 class Rect;
25 namespace views {
26 class Widget;
29 namespace ash {
31 // LayoutManager for the modal window container.
32 // System modal windows which are centered on the screen will be kept centered
33 // when the container size changes.
34 class ASH_EXPORT SystemModalContainerLayoutManager
35 : public SnapToPixelLayoutManager,
36 public aura::WindowObserver,
37 public keyboard::KeyboardControllerObserver {
38 public:
39 explicit SystemModalContainerLayoutManager(aura::Window* container);
40 ~SystemModalContainerLayoutManager() override;
42 bool has_modal_background() const { return modal_background_ != NULL; }
44 // Overridden from SnapToPixelLayoutManager:
45 void OnWindowResized() override;
46 void OnWindowAddedToLayout(aura::Window* child) override;
47 void OnWillRemoveWindowFromLayout(aura::Window* child) override;
48 void SetChildBounds(aura::Window* child,
49 const gfx::Rect& requested_bounds) override;
51 // Overridden from aura::WindowObserver:
52 void OnWindowPropertyChanged(aura::Window* window,
53 const void* key,
54 intptr_t old) override;
55 void OnWindowDestroying(aura::Window* window) override;
57 // Overridden from keyboard::KeyboardControllerObserver:
58 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
60 // Can a given |window| receive and handle input events?
61 bool CanWindowReceiveEvents(aura::Window* window);
63 // Activates next modal window if any. Returns false if there
64 // are no more modal windows in this layout manager.
65 bool ActivateNextModalWindow();
67 // Creates modal background window, which is a partially-opaque
68 // fullscreen window. If there is already a modal background window,
69 // it will bring it the top.
70 void CreateModalBackground();
72 void DestroyModalBackground();
74 // Is the |window| modal background?
75 static bool IsModalBackground(aura::Window* window);
77 private:
78 void AddModalWindow(aura::Window* window);
79 void RemoveModalWindow(aura::Window* window);
81 // Reposition the dialogs to become visible after the work area changes.
82 void PositionDialogsAfterWorkAreaResize();
84 // Get the usable bounds rectangle for enclosed dialogs.
85 gfx::Rect GetUsableDialogArea();
87 // Gets the new bounds for a |window| to use which are either centered (if the
88 // window was previously centered) or fitted to the screen.
89 gfx::Rect GetCenteredAndOrFittedBounds(const aura::Window* window);
91 // Returns true if |window_bounds| is centered.
92 bool DialogIsCentered(const gfx::Rect& window_bounds);
94 aura::Window* modal_window() {
95 return !modal_windows_.empty() ? modal_windows_.back() : NULL;
98 // The container that owns the layout manager.
99 aura::Window* container_;
101 // A widget that dims the windows behind the modal window(s) being
102 // shown in |container_|.
103 views::Widget* modal_background_;
105 // A stack of modal windows. Only the topmost can receive events.
106 std::vector<aura::Window*> modal_windows_;
108 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager);
111 } // namespace ash
113 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_