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

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

Issue 2336653002: Ports SystemModalContainerLayoutManager to ash/common (Closed)
Patch Set: merge again 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
« no previous file with comments | « ash/wm/screen_pinning_controller.cc ('k') | ash/wm/system_modal_container_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "ash/ash_export.h"
12 #include "ash/snap_to_pixel_layout_manager.h"
13 #include "base/compiler_specific.h"
14 #include "base/macros.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/keyboard/keyboard_controller_observer.h"
17
18 namespace aura {
19 class Window;
20 class EventFilter;
21 }
22 namespace gfx {
23 class Rect;
24 }
25
26 namespace ash {
27 class WindowDimmer;
28
29 // LayoutManager for the modal window container.
30 // System modal windows which are centered on the screen will be kept centered
31 // when the container size changes.
32 class ASH_EXPORT SystemModalContainerLayoutManager
33 : public SnapToPixelLayoutManager,
34 public aura::WindowObserver,
35 public keyboard::KeyboardControllerObserver {
36 public:
37 explicit SystemModalContainerLayoutManager(aura::Window* container);
38 ~SystemModalContainerLayoutManager() override;
39
40 bool has_window_dimmer() const { return window_dimmer_ != nullptr; }
41
42 // Overridden from SnapToPixelLayoutManager:
43 void OnWindowResized() override;
44 void OnWindowAddedToLayout(aura::Window* child) override;
45 void OnWillRemoveWindowFromLayout(aura::Window* child) override;
46 void SetChildBounds(aura::Window* child,
47 const gfx::Rect& requested_bounds) override;
48
49 // Overridden from aura::WindowObserver:
50 void OnWindowPropertyChanged(aura::Window* window,
51 const void* key,
52 intptr_t old) override;
53 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
54
55 // Overridden from keyboard::KeyboardControllerObserver:
56 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
57
58 // True if the window is either contained by the top most modal window,
59 // or contained by its transient children.
60 bool IsPartOfActiveModalWindow(aura::Window* window);
61
62 // Activates next modal window if any. Returns false if there
63 // are no more modal windows in this layout manager.
64 bool ActivateNextModalWindow();
65
66 // Creates modal background window, which is a partially-opaque
67 // fullscreen window. If there is already a modal background window,
68 // it will bring it the top.
69 void CreateModalBackground();
70
71 void DestroyModalBackground();
72
73 // Is the |window| modal background?
74 static bool IsModalBackground(aura::Window* window);
75
76 private:
77 void AddModalWindow(aura::Window* window);
78 void RemoveModalWindow(aura::Window* 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();
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 aura::Window* window);
89
90 // Returns true if |window_bounds| is centered.
91 bool DialogIsCentered(const gfx::Rect& window_bounds);
92
93 aura::Window* modal_window() {
94 return !modal_windows_.empty() ? modal_windows_.back() : NULL;
95 }
96
97 // The container that owns the layout manager.
98 aura::Window* 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<aura::Window*> modal_windows_;
106
107 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager);
108 };
109
110 } // namespace ash
111
112 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/wm/screen_pinning_controller.cc ('k') | ash/wm/system_modal_container_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698