| 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_BASE_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_BASE_LAYOUT_MANAGER_H_ |
| 6 #define ASH_WM_BASE_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_BASE_LAYOUT_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "ash/shell_observer.h" |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
| 15 #include "ui/aura/root_window_observer.h" | 16 #include "ui/aura/root_window_observer.h" |
| 16 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 class Window; | 20 class Window; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace ash { | 23 namespace ash { |
| 23 namespace internal { | 24 namespace internal { |
| 24 | 25 |
| 25 // BaseLayoutManager is the simplest possible implementation for a window | 26 // BaseLayoutManager is the simplest possible implementation for a window |
| 26 // layout manager. It listens for changes to kShowStateKey and resizes the | 27 // layout manager. It listens for changes to kShowStateKey and resizes the |
| 27 // window appropriately. Subclasses should be sure to invoke the base class | 28 // window appropriately. Subclasses should be sure to invoke the base class |
| 28 // for adding and removing windows, otherwise show state will not be tracked | 29 // for adding and removing windows, otherwise show state will not be tracked |
| 29 // properly. | 30 // properly. |
| 30 class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, | 31 class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, |
| 31 public aura::RootWindowObserver, | 32 public aura::RootWindowObserver, |
| 33 public ash::ShellObserver, |
| 32 public aura::WindowObserver { | 34 public aura::WindowObserver { |
| 33 public: | 35 public: |
| 34 typedef std::set<aura::Window*> WindowSet; | 36 typedef std::set<aura::Window*> WindowSet; |
| 35 | 37 |
| 36 BaseLayoutManager(); | 38 BaseLayoutManager(); |
| 37 virtual ~BaseLayoutManager(); | 39 virtual ~BaseLayoutManager(); |
| 38 | 40 |
| 39 const WindowSet& windows() const { return windows_; } | 41 const WindowSet& windows() const { return windows_; } |
| 40 | 42 |
| 41 // LayoutManager overrides: | 43 // LayoutManager overrides: |
| 42 virtual void OnWindowResized() OVERRIDE; | 44 virtual void OnWindowResized() OVERRIDE; |
| 43 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; | 45 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
| 44 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; | 46 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; |
| 45 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 47 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 46 bool visible) OVERRIDE; | 48 bool visible) OVERRIDE; |
| 47 virtual void SetChildBounds(aura::Window* child, | 49 virtual void SetChildBounds(aura::Window* child, |
| 48 const gfx::Rect& requested_bounds) OVERRIDE; | 50 const gfx::Rect& requested_bounds) OVERRIDE; |
| 49 | 51 |
| 50 // RootWindowObserver overrides: | 52 // RootWindowObserver overrides: |
| 51 virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; | 53 virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; |
| 54 |
| 55 // ash::ShellObserver overrides: |
| 52 virtual void OnScreenWorkAreaInsetsChanged() OVERRIDE; | 56 virtual void OnScreenWorkAreaInsetsChanged() OVERRIDE; |
| 53 | 57 |
| 54 // WindowObserver overrides: | 58 // WindowObserver overrides: |
| 55 virtual void OnWindowPropertyChanged(aura::Window* window, | 59 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 56 const void* key, | 60 const void* key, |
| 57 intptr_t old) OVERRIDE; | 61 intptr_t old) OVERRIDE; |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 // Update window bounds based on a change in show state. | 64 // Update window bounds based on a change in show state. |
| 61 void UpdateBoundsFromShowState(aura::Window* window); | 65 void UpdateBoundsFromShowState(aura::Window* window); |
| 62 | 66 |
| 63 // Adjusts the window sizes when the screen changes its size or its | 67 // Adjusts the window sizes when the screen changes its size or its |
| 64 // work area insets. | 68 // work area insets. |
| 65 void AdjustWindowSizesForScreenChange(); | 69 void AdjustWindowSizesForScreenChange(); |
| 66 | 70 |
| 67 // Set of windows we're listening to. | 71 // Set of windows we're listening to. |
| 68 WindowSet windows_; | 72 WindowSet windows_; |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager); | 74 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager); |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 } // namespace internal | 77 } // namespace internal |
| 74 } // namespace ash | 78 } // namespace ash |
| 75 | 79 |
| 76 #endif // ASH_WM_BASE_LAYOUT_MANAGER_H_ | 80 #endif // ASH_WM_BASE_LAYOUT_MANAGER_H_ |
| OLD | NEW |