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

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

Issue 2336653002: Ports SystemModalContainerLayoutManager to ash/common (Closed)
Patch Set: cleanup Created 4 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ 5 #ifndef ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ 6 #define ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set>
9 #include <vector> 10 #include <vector>
10 11
11 #include "ash/ash_export.h" 12 #include "ash/ash_export.h"
12 #include "ash/snap_to_pixel_layout_manager.h" 13 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h"
13 #include "base/compiler_specific.h" 14 #include "ash/common/wm_window_observer.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/keyboard/keyboard_controller_observer.h" 16 #include "ui/keyboard/keyboard_controller_observer.h"
17 17
18 namespace aura {
19 class Window;
20 class EventFilter;
21 }
22 namespace gfx { 18 namespace gfx {
23 class Rect; 19 class Rect;
24 } 20 }
25 21
26 namespace ash { 22 namespace ash {
27 class WindowDimmer; 23 class WindowDimmer;
28 24
29 // LayoutManager for the modal window container. 25 // LayoutManager for the modal window container.
30 // System modal windows which are centered on the screen will be kept centered 26 // System modal windows which are centered on the screen will be kept centered
31 // when the container size changes. 27 // when the container size changes.
32 class ASH_EXPORT SystemModalContainerLayoutManager 28 class ASH_EXPORT SystemModalContainerLayoutManager
33 : public SnapToPixelLayoutManager, 29 : public wm::WmSnapToPixelLayoutManager,
34 public aura::WindowObserver, 30 public WmWindowObserver,
35 public keyboard::KeyboardControllerObserver { 31 public keyboard::KeyboardControllerObserver {
36 public: 32 public:
37 explicit SystemModalContainerLayoutManager(aura::Window* container); 33 explicit SystemModalContainerLayoutManager(WmWindow* container);
38 ~SystemModalContainerLayoutManager() override; 34 ~SystemModalContainerLayoutManager() override;
39 35
40 bool has_window_dimmer() const { return window_dimmer_ != nullptr; } 36 bool has_window_dimmer() const { return window_dimmer_ != nullptr; }
41 37
42 // Overridden from SnapToPixelLayoutManager: 38 // Overridden from WmSnapToPixelLayoutManager:
43 void OnWindowResized() override; 39 void OnWindowResized() override;
44 void OnWindowAddedToLayout(aura::Window* child) override; 40 void OnWindowAddedToLayout(WmWindow* child) override;
45 void OnWillRemoveWindowFromLayout(aura::Window* child) override; 41 void OnWillRemoveWindowFromLayout(WmWindow* child) override;
46 void SetChildBounds(aura::Window* child, 42 void SetChildBounds(WmWindow* child,
47 const gfx::Rect& requested_bounds) override; 43 const gfx::Rect& requested_bounds) override;
48 44
49 // Overridden from aura::WindowObserver: 45 // Overridden from aura::WindowObserver:
James Cook 2016/09/12 19:24:28 nit: WmWindowObserver
sky 2016/09/12 20:46:54 Done.
50 void OnWindowPropertyChanged(aura::Window* window, 46 void OnWindowPropertyChanged(WmWindow* window,
51 const void* key, 47 WmWindowProperty property) override;
52 intptr_t old) override; 48 void OnWindowVisibilityChanged(WmWindow* window, bool visible) override;
53 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
54 49
55 // Overridden from keyboard::KeyboardControllerObserver: 50 // Overridden from keyboard::KeyboardControllerObserver:
56 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; 51 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
57 52
58 // True if the window is either contained by the top most modal window, 53 // True if the window is either contained by the top most modal window,
59 // or contained by its transient children. 54 // or contained by its transient children.
60 bool IsPartOfActiveModalWindow(aura::Window* window); 55 bool IsPartOfActiveModalWindow(WmWindow* window);
61 56
62 // Activates next modal window if any. Returns false if there 57 // Activates next modal window if any. Returns false if there
63 // are no more modal windows in this layout manager. 58 // are no more modal windows in this layout manager.
64 bool ActivateNextModalWindow(); 59 bool ActivateNextModalWindow();
65 60
66 // Creates modal background window, which is a partially-opaque 61 // Creates modal background window, which is a partially-opaque
67 // fullscreen window. If there is already a modal background window, 62 // fullscreen window. If there is already a modal background window,
68 // it will bring it the top. 63 // it will bring it the top.
69 void CreateModalBackground(); 64 void CreateModalBackground();
70 65
71 void DestroyModalBackground(); 66 void DestroyModalBackground();
72 67
73 // Is the |window| modal background? 68 // Is the |window| modal background?
74 static bool IsModalBackground(aura::Window* window); 69 static bool IsModalBackground(WmWindow* window);
75 70
76 private: 71 private:
77 void AddModalWindow(aura::Window* window); 72 void AddModalWindow(WmWindow* window);
78 void RemoveModalWindow(aura::Window* window); 73
74 // Removes |window| from |modal_windows_|. Returns true if |window| was in
75 // |modal_windows_|.
76 bool RemoveModalWindow(WmWindow* window);
79 77
80 // Reposition the dialogs to become visible after the work area changes. 78 // Reposition the dialogs to become visible after the work area changes.
81 void PositionDialogsAfterWorkAreaResize(); 79 void PositionDialogsAfterWorkAreaResize();
82 80
83 // Get the usable bounds rectangle for enclosed dialogs. 81 // Get the usable bounds rectangle for enclosed dialogs.
84 gfx::Rect GetUsableDialogArea(); 82 gfx::Rect GetUsableDialogArea() const;
85 83
86 // Gets the new bounds for a |window| to use which are either centered (if the 84 // 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. 85 // window was previously centered) or fitted to the screen.
88 gfx::Rect GetCenteredAndOrFittedBounds(const aura::Window* window); 86 gfx::Rect GetCenteredAndOrFittedBounds(const WmWindow* window);
89 87
90 // Returns true if |window_bounds| is centered. 88 // Returns true if |bounds| is considered centered.
91 bool DialogIsCentered(const gfx::Rect& window_bounds); 89 bool IsBoundsCentered(const gfx::Rect& window_bounds) const;
92 90
93 aura::Window* modal_window() { 91 WmWindow* modal_window() {
94 return !modal_windows_.empty() ? modal_windows_.back() : NULL; 92 return !modal_windows_.empty() ? modal_windows_.back() : nullptr;
95 } 93 }
96 94
97 // The container that owns the layout manager. 95 // The container that owns the layout manager.
98 aura::Window* container_; 96 WmWindow* container_;
99 97
100 // WindowDimmer used to dim windows behind the modal window(s) being shown in 98 // WindowDimmer used to dim windows behind the modal window(s) being shown in
101 // |container_|. 99 // |container_|.
102 std::unique_ptr<WindowDimmer> window_dimmer_; 100 std::unique_ptr<WindowDimmer> window_dimmer_;
103 101
104 // A stack of modal windows. Only the topmost can receive events. 102 // A stack of modal windows. Only the topmost can receive events.
105 std::vector<aura::Window*> modal_windows_; 103 std::vector<WmWindow*> modal_windows_;
104
105 // Windows contained in this set are centered. Windows are automatically
106 // added to this based on IsBoundsCentered().
107 std::set<const WmWindow*> windows_to_center_;
106 108
107 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager); 109 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager);
108 }; 110 };
109 111
110 } // namespace ash 112 } // namespace ash
111 113
112 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ 114 #endif // ASH_COMMON_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698