| OLD | NEW |
| 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_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
| 6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 11 #include "ash/snap_to_pixel_layout_manager.h" | 12 #include "ash/snap_to_pixel_layout_manager.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
| 15 #include "ui/keyboard/keyboard_controller_observer.h" | 16 #include "ui/keyboard/keyboard_controller_observer.h" |
| 16 | 17 |
| 17 namespace aura { | 18 namespace aura { |
| 18 class Window; | 19 class Window; |
| 19 class EventFilter; | 20 class EventFilter; |
| 20 } | 21 } |
| 21 namespace gfx { | 22 namespace gfx { |
| 22 class Rect; | 23 class Rect; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace ash { | 26 namespace ash { |
| 26 class DimWindow; | 27 class WindowDimmer; |
| 27 | 28 |
| 28 // LayoutManager for the modal window container. | 29 // LayoutManager for the modal window container. |
| 29 // System modal windows which are centered on the screen will be kept centered | 30 // System modal windows which are centered on the screen will be kept centered |
| 30 // when the container size changes. | 31 // when the container size changes. |
| 31 class ASH_EXPORT SystemModalContainerLayoutManager | 32 class ASH_EXPORT SystemModalContainerLayoutManager |
| 32 : public SnapToPixelLayoutManager, | 33 : public SnapToPixelLayoutManager, |
| 33 public aura::WindowObserver, | 34 public aura::WindowObserver, |
| 34 public keyboard::KeyboardControllerObserver { | 35 public keyboard::KeyboardControllerObserver { |
| 35 public: | 36 public: |
| 36 explicit SystemModalContainerLayoutManager(aura::Window* container); | 37 explicit SystemModalContainerLayoutManager(aura::Window* container); |
| 37 ~SystemModalContainerLayoutManager() override; | 38 ~SystemModalContainerLayoutManager() override; |
| 38 | 39 |
| 39 bool has_modal_background() const { return modal_background_ != NULL; } | 40 bool has_window_dimmer() const { return window_dimmer_ != nullptr; } |
| 40 | 41 |
| 41 // Overridden from SnapToPixelLayoutManager: | 42 // Overridden from SnapToPixelLayoutManager: |
| 42 void OnWindowResized() override; | 43 void OnWindowResized() override; |
| 43 void OnWindowAddedToLayout(aura::Window* child) override; | 44 void OnWindowAddedToLayout(aura::Window* child) override; |
| 44 void OnWillRemoveWindowFromLayout(aura::Window* child) override; | 45 void OnWillRemoveWindowFromLayout(aura::Window* child) override; |
| 45 void SetChildBounds(aura::Window* child, | 46 void SetChildBounds(aura::Window* child, |
| 46 const gfx::Rect& requested_bounds) override; | 47 const gfx::Rect& requested_bounds) override; |
| 47 | 48 |
| 48 // Overridden from aura::WindowObserver: | 49 // Overridden from aura::WindowObserver: |
| 49 void OnWindowPropertyChanged(aura::Window* window, | 50 void OnWindowPropertyChanged(aura::Window* window, |
| 50 const void* key, | 51 const void* key, |
| 51 intptr_t old) override; | 52 intptr_t old) override; |
| 52 void OnWindowDestroying(aura::Window* window) override; | |
| 53 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 53 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
| 54 | 54 |
| 55 // Overridden from keyboard::KeyboardControllerObserver: | 55 // Overridden from keyboard::KeyboardControllerObserver: |
| 56 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | 56 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; |
| 57 | 57 |
| 58 // True if the window is either contained by the top most modal window, | 58 // True if the window is either contained by the top most modal window, |
| 59 // or contained by its transient children. | 59 // or contained by its transient children. |
| 60 bool IsPartOfActiveModalWindow(aura::Window* window); | 60 bool IsPartOfActiveModalWindow(aura::Window* window); |
| 61 | 61 |
| 62 // Activates next modal window if any. Returns false if there | 62 // Activates next modal window if any. Returns false if there |
| (...skipping 27 matching lines...) Expand all Loading... |
| 90 // Returns true if |window_bounds| is centered. | 90 // Returns true if |window_bounds| is centered. |
| 91 bool DialogIsCentered(const gfx::Rect& window_bounds); | 91 bool DialogIsCentered(const gfx::Rect& window_bounds); |
| 92 | 92 |
| 93 aura::Window* modal_window() { | 93 aura::Window* modal_window() { |
| 94 return !modal_windows_.empty() ? modal_windows_.back() : NULL; | 94 return !modal_windows_.empty() ? modal_windows_.back() : NULL; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // The container that owns the layout manager. | 97 // The container that owns the layout manager. |
| 98 aura::Window* container_; | 98 aura::Window* container_; |
| 99 | 99 |
| 100 // A window that dims the windows behind the modal window(s) being | 100 // WindowDimmer used to dim windows behind the modal window(s) being shown in |
| 101 // shown in |container_|. | 101 // |container_|. |
| 102 DimWindow* modal_background_; | 102 std::unique_ptr<WindowDimmer> window_dimmer_; |
| 103 | 103 |
| 104 // A stack of modal windows. Only the topmost can receive events. | 104 // A stack of modal windows. Only the topmost can receive events. |
| 105 std::vector<aura::Window*> modal_windows_; | 105 std::vector<aura::Window*> modal_windows_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager); | 107 DISALLOW_COPY_AND_ASSIGN(SystemModalContainerLayoutManager); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace ash | 110 } // namespace ash |
| 111 | 111 |
| 112 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ | 112 #endif // ASH_WM_SYSTEM_MODAL_CONTAINER_LAYOUT_MANAGER_H_ |
| OLD | NEW |