906a04a33b2d5c67879dbb5665e98eaa3f51288e
[platform/framework/web/crosswalk.git] / src / ash / wm / workspace / workspace_layout_manager.h
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_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
7
8 #include <set>
9
10 #include "ash/shell_observer.h"
11 #include "ash/wm/base_layout_manager.h"
12 #include "ash/wm/wm_types.h"
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/gfx/rect.h"
17
18 namespace aura {
19 class RootWindow;
20 class Window;
21 }
22
23 namespace ui {
24 class Layer;
25 }
26
27 namespace ash {
28
29 namespace internal {
30
31 class ShelfLayoutManager;
32
33 // LayoutManager used on the window created for a workspace.
34 class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
35  public:
36   explicit WorkspaceLayoutManager(aura::Window* window);
37   virtual ~WorkspaceLayoutManager();
38
39   void SetShelf(internal::ShelfLayoutManager* shelf);
40
41   // Overridden from aura::LayoutManager:
42   virtual void OnWindowResized() OVERRIDE {}
43   virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
44   virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
45   virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
46   virtual void OnChildWindowVisibilityChanged(aura::Window* child,
47                                               bool visibile) OVERRIDE;
48   virtual void SetChildBounds(aura::Window* child,
49                               const gfx::Rect& requested_bounds) OVERRIDE;
50
51   // ash::ShellObserver overrides:
52   virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE;
53
54   // Overriden from WindowObserver:
55   virtual void OnWindowPropertyChanged(aura::Window* window,
56                                        const void* key,
57                                        intptr_t old) OVERRIDE;
58   virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE;
59
60   // WindowStateObserver overrides:
61   virtual void OnWindowShowTypeChanged(wm::WindowState* window_state,
62                                        wm::WindowShowType old_type) OVERRIDE;
63
64  private:
65   // Overridden from BaseLayoutManager:
66   virtual void AdjustAllWindowsBoundsForWorkAreaChange(
67       AdjustWindowReason reason) OVERRIDE;
68   virtual void AdjustWindowBoundsForWorkAreaChange(
69       wm::WindowState* window_state,
70       AdjustWindowReason reason) OVERRIDE;
71
72   void AdjustWindowBoundsWhenAdded(wm::WindowState* window_state);
73
74   // Updates the visibility state of the shelf.
75   void UpdateShelfVisibility();
76
77   // Updates the fullscreen state of the workspace and notifies Shell if it
78   // has changed.
79   void UpdateFullscreenState();
80
81   // Updates the bounds of the window for a show type change from
82   // |old_show_type|.
83   void UpdateBoundsFromShowType(wm::WindowState* window_state,
84                                 wm::WindowShowType old_show_type);
85
86   // If |window_state| is maximized or fullscreen the bounds of the
87   // window are set and true is returned. Does nothing otherwise.
88   bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
89
90   // Adjusts the |bounds| so that they are flush with the edge of the
91   // workspace if the window represented by |window_state| is side snapped.
92   void AdjustSnappedBounds(wm::WindowState* window_state, gfx::Rect* bounds);
93
94   // Animates the window bounds to |bounds|.
95   void SetChildBoundsAnimated(aura::Window* child, const gfx::Rect& bounds);
96
97   internal::ShelfLayoutManager* shelf_;
98   aura::Window* window_;
99
100   // The work area in the coordinates of |window_|.
101   gfx::Rect work_area_in_parent_;
102
103   // True if this workspace is currently in fullscreen mode.
104   bool is_fullscreen_;
105
106   DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager);
107 };
108
109 }  // namespace internal
110 }  // namespace ash
111
112 #endif  // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_