Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: ash/common/wm/system_modal_container_layout_manager.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
6 #define ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
7
8 #include <memory>
9 #include <set>
10 #include <vector>
11
12 #include "ash/ash_export.h"
13 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h"
14 #include "base/macros.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/keyboard/keyboard_controller_observer.h"
17
18 namespace gfx {
19 class Rect;
20 }
21
22 namespace ash {
23 class WindowDimmer;
24
25 // LayoutManager for the modal window container.
26 // System modal windows which are centered on the screen will be kept centered
27 // when the container size changes.
28 class ASH_EXPORT SystemModalContainerLayoutManager
29 : public wm::WmSnapToPixelLayoutManager,
30 public aura::WindowObserver,
31 public keyboard::KeyboardControllerObserver {
32 public:
33 explicit SystemModalContainerLayoutManager(WmWindow* container);
34 ~SystemModalContainerLayoutManager() override;
35
36 bool has_window_dimmer() const { return window_dimmer_ != nullptr; }
37
38 // Overridden from WmSnapToPixelLayoutManager:
39 void OnChildWindowVisibilityChanged(WmWindow* child, bool visible) override;
40 void OnWindowResized() override;
41 void OnWindowAddedToLayout(WmWindow* child) override;
42 void OnWillRemoveWindowFromLayout(WmWindow* child) override;
43 void SetChildBounds(WmWindow* child,
44 const gfx::Rect& requested_bounds) override;
45
46 // Overridden from aura::WindowObserver:
47 void OnWindowPropertyChanged(aura::Window* window,
48 const void* key,
49 intptr_t old) override;
50
51 // Overridden from keyboard::KeyboardControllerObserver:
52 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
53 void OnKeyboardClosed() override;
54
55 // True if the window is either contained by the top most modal window,
56 // or contained by its transient children.
57 bool IsPartOfActiveModalWindow(WmWindow* window);
58
59 // Activates next modal window if any. Returns false if there
60 // are no more modal windows in this layout manager.
61 bool ActivateNextModalWindow();
62
63 // Creates modal background window, which is a partially-opaque
64 // fullscreen window. If there is already a modal background window,
65 // it will bring it the top.
66 void CreateModalBackground();
67
68 void DestroyModalBackground();
69
70 // Is the |window| modal background?
71 static bool IsModalBackground(WmWindow* window);
72
73 private:
74 void AddModalWindow(WmWindow* window);
75
76 // Removes |window| from |modal_windows_|. Returns true if |window| was in
77 // |modal_windows_|.
78 bool RemoveModalWindow(WmWindow* window);
79
80 // Reposition the dialogs to become visible after the work area changes.
81 void PositionDialogsAfterWorkAreaResize();
82
83 // Get the usable bounds rectangle for enclosed dialogs.
84 gfx::Rect GetUsableDialogArea() const;
85
86 // Gets the new bounds for a |window| to use which are either centered (if the
87 // window was previously centered) or fitted to the screen.
88 gfx::Rect GetCenteredAndOrFittedBounds(const WmWindow* window);
89
90 // Returns true if |bounds| is considered centered.
91 bool IsBoundsCentered(const gfx::Rect& window_bounds) const;
92
93 WmWindow* modal_window() {
94 return !modal_windows_.empty() ? modal_windows_.back() : nullptr;
95 }
96
97 // The container that owns the layout manager.
98 WmWindow* container_;
99
100 // WindowDimmer used to dim windows behind the modal window(s) being shown in
101 // |container_|.
102 std::unique_ptr<WindowDimmer> window_dimmer_;
103
104 // A stack of modal windows. Only the topmost can receive events.
105 std::vector<WmWindow*> modal_windows_;
106
107 // Windows contained in this set are centered. Windows are automatically
108 // added to this based on IsBoundsCentered().
109 std::set<const WmWindow*> windows_to_center_;
110
111 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager);
112 };
113
114 } // namespace ash
115
116 #endif // ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/common/wm/switchable_windows.cc ('k') | ash/common/wm/system_modal_container_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698