| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | 5 #ifndef UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ |
| 6 #define UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | 6 #define UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" |
| 13 #include "ui/aura/desktop_observer.h" |
| 11 #include "ui/aura_shell/aura_shell_export.h" | 14 #include "ui/aura_shell/aura_shell_export.h" |
| 15 #include "ui/gfx/insets.h" |
| 12 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 13 | 17 |
| 14 namespace aura { | 18 namespace aura { |
| 15 class Window; | 19 class Window; |
| 16 } | 20 } |
| 17 | 21 |
| 22 namespace gfx { |
| 23 class Point; |
| 24 class Rect; |
| 25 } |
| 26 |
| 18 namespace aura_shell { | 27 namespace aura_shell { |
| 19 class Workspace; | 28 class Workspace; |
| 20 | 29 |
| 21 // WorkspaceManager manages multiple workspaces in the desktop. | 30 // WorkspaceManager manages multiple workspaces in the desktop. |
| 22 class AURA_SHELL_EXPORT WorkspaceManager { | 31 class AURA_SHELL_EXPORT WorkspaceManager : public aura::DesktopObserver { |
| 23 public: | 32 public: |
| 24 explicit WorkspaceManager(); | 33 explicit WorkspaceManager(aura::Window* viewport); |
| 25 virtual ~WorkspaceManager(); | 34 virtual ~WorkspaceManager(); |
| 26 | 35 |
| 27 // Create new workspace. Workspace objects are managed by | 36 // Create new workspace. Workspace objects are managed by |
| 28 // this WorkspaceManager. Deleting workspace will automatically | 37 // this WorkspaceManager. Deleting workspace will automatically |
| 29 // remove the workspace from the workspace_manager. | 38 // remove the workspace from the workspace_manager. |
| 30 Workspace* CreateWorkspace(); | 39 Workspace* CreateWorkspace(); |
| 31 | 40 |
| 32 // Returns the active workspace. | 41 // Returns the active workspace. |
| 33 Workspace* GetActiveWorkspace() const; | 42 Workspace* GetActiveWorkspace() const; |
| 34 | 43 |
| 35 // Returns the workspace that contanis the |window|. | 44 // Returns the workspace that contanis the |window|. |
| 36 Workspace* FindBy(aura::Window* window) const; | 45 Workspace* FindBy(aura::Window* window) const; |
| 37 | 46 |
| 38 // Sets the bounds of all workspaces. | 47 // Sets the bounds of all workspaces. |
| 39 void Layout(); | 48 void LayoutWorkspaces(); |
| 40 | 49 |
| 41 // Returns the total width of all workspaces. | 50 // Returns the bounds in which a window can be moved/resized. |
| 42 int GetTotalWidth() const; | 51 gfx::Rect GetDragAreaBounds(); |
| 43 | 52 |
| 44 // Sets/gets the size of the workspace. | 53 // Turn on/off overview mode. |
| 45 void set_workspace_size(const gfx::Size& size) { workspace_size_ = size; } | 54 void SetOverview(bool overview); |
| 46 const gfx::Size& workspace_size() const { return workspace_size_; } | 55 bool is_overview() const { return is_overview_; } |
| 56 |
| 57 // Overridden from aura::DesktopObserver: |
| 58 virtual void OnDesktopResized(const gfx::Size& new_size) OVERRIDE; |
| 59 virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE; |
| 47 | 60 |
| 48 private: | 61 private: |
| 49 friend class Workspace; | 62 friend class Workspace; |
| 63 FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, Overview); |
| 64 FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, LayoutWorkspaces); |
| 50 | 65 |
| 51 void AddWorkspace(Workspace* workspace); | 66 void AddWorkspace(Workspace* workspace); |
| 52 void RemoveWorkspace(Workspace* workspace); | 67 void RemoveWorkspace(Workspace* workspace); |
| 53 | 68 |
| 54 // Sets the active workspace. | 69 // Sets the active workspace. |
| 55 void SetActiveWorkspace(Workspace* workspace); | 70 void SetActiveWorkspace(Workspace* workspace); |
| 56 | 71 |
| 57 gfx::Size workspace_size_; | 72 // Returns the bounds of the work are given |workspace_bounds|. |
| 73 gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds); |
| 74 |
| 75 // Update viewport size and move to the active workspace. |
| 76 void UpdateViewport(); |
| 77 |
| 78 aura::Window* viewport_; |
| 58 | 79 |
| 59 Workspace* active_workspace_; | 80 Workspace* active_workspace_; |
| 60 | 81 |
| 61 std::vector<Workspace*> workspaces_; | 82 std::vector<Workspace*> workspaces_; |
| 62 | 83 |
| 84 // The size of a single workspace. This is generally the same as the size of |
| 85 // monitor. |
| 86 gfx::Size workspace_size_; |
| 87 |
| 88 // True if the workspace manager is in overview mode. |
| 89 bool is_overview_; |
| 90 |
| 63 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | 91 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); |
| 64 }; | 92 }; |
| 65 | 93 |
| 66 } // namespace aura_shell | 94 } // namespace aura_shell |
| 67 | 95 |
| 68 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | 96 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ |
| OLD | NEW |