Chromium Code Reviews| 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 "ui/aura/desktop_observer.h" | |
| 11 #include "ui/aura_shell/aura_shell_export.h" | 13 #include "ui/aura_shell/aura_shell_export.h" |
| 14 #include "ui/gfx/insets.h" | |
| 12 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
| 13 | 16 |
| 14 namespace aura { | 17 namespace aura { |
| 15 class Window; | 18 class Window; |
| 16 } | 19 } |
| 17 | 20 |
| 21 namespace gfx { | |
| 22 class Point; | |
| 23 class Rect; | |
| 24 } | |
| 25 | |
| 18 namespace aura_shell { | 26 namespace aura_shell { |
| 27 | |
| 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 : aura::DesktopObserver { |
|
sky
2011/10/25 20:58:05
public aura::DesktopObserver
oshima
2011/10/25 23:37:23
Done.
| |
| 23 public: | 32 public: |
| 24 explicit WorkspaceManager(); | 33 explicit WorkspaceManager(aura::Window* viewport); |
| 25 virtual ~WorkspaceManager(); | 34 virtual ~WorkspaceManager(); |
| 26 | 35 |
| 36 void set_work_area_insets(const gfx::Insets& insets) { | |
| 37 work_area_insets_ = insets; | |
|
sky
2011/10/25 20:58:05
Caching the insets here and in screen makes it eas
oshima
2011/10/25 23:37:23
Good point. Done.
| |
| 38 } | |
| 39 | |
| 27 // Create new workspace. Workspace objects are managed by | 40 // Create new workspace. Workspace objects are managed by |
| 28 // this WorkspaceManager. Deleting workspace will automatically | 41 // this WorkspaceManager. Deleting workspace will automatically |
| 29 // remove the workspace from the workspace_manager. | 42 // remove the workspace from the workspace_manager. |
| 30 Workspace* CreateWorkspace(); | 43 Workspace* CreateWorkspace(); |
| 31 | 44 |
| 32 // Returns the active workspace. | 45 // Returns the active workspace. |
| 33 Workspace* GetActiveWorkspace() const; | 46 Workspace* GetActiveWorkspace() const; |
| 34 | 47 |
| 35 // Returns the workspace that contanis the |window|. | 48 // Returns the workspace that contanis the |window|. |
| 36 Workspace* FindBy(aura::Window* window) const; | 49 Workspace* FindBy(aura::Window* window) const; |
| 37 | 50 |
| 38 // Sets the bounds of all workspaces. | 51 // Sets the bounds of all workspaces. |
| 39 void Layout(); | 52 void LayoutWorkspaces(); |
| 40 | 53 |
| 41 // Returns the total width of all workspaces. | 54 // Returns |
|
sky
2011/10/25 20:58:05
Document this.
oshima
2011/10/25 23:37:23
Done.
| |
| 42 int GetTotalWidth() const; | 55 gfx::Rect GetDragAreaBounds(); |
| 43 | 56 |
| 44 // Sets/gets the size of the workspace. | 57 // Turn on/off overview mode. |
| 45 void set_workspace_size(const gfx::Size& size) { workspace_size_ = size; } | 58 void SetOverview(bool overview); |
| 46 const gfx::Size& workspace_size() const { return workspace_size_; } | 59 bool is_overview() const { return is_overview_; } |
| 60 | |
| 61 // Overridden from aura::DesktopObserver: | |
| 62 virtual void OnDesktopResized(const gfx::Size& new_size) OVERRIDE; | |
| 63 virtual void OnActiveWindowChanged(aura::Window* active) OVERRIDE; | |
| 47 | 64 |
| 48 private: | 65 private: |
| 49 friend class Workspace; | 66 friend class Workspace; |
| 50 | 67 |
| 51 void AddWorkspace(Workspace* workspace); | 68 void AddWorkspace(Workspace* workspace); |
| 52 void RemoveWorkspace(Workspace* workspace); | 69 void RemoveWorkspace(Workspace* workspace); |
| 53 | 70 |
| 54 // Sets the active workspace. | 71 // Sets the active workspace. |
| 55 void SetActiveWorkspace(Workspace* workspace); | 72 void SetActiveWorkspace(Workspace* workspace); |
| 56 | 73 |
| 57 gfx::Size workspace_size_; | 74 // Returns the work area for given |workspace_bounds| by appliing |
| 75 // the |work_area_insets_|. | |
|
sky
2011/10/25 20:58:05
Returns the bounds of the work area given the work
oshima
2011/10/25 23:37:23
Done.
| |
| 76 gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds); | |
| 77 | |
| 78 // Update viewport size and move to active workspace. | |
| 79 void UpdateViewport(); | |
| 80 | |
| 81 aura::Window* viewport_; | |
| 58 | 82 |
| 59 Workspace* active_workspace_; | 83 Workspace* active_workspace_; |
| 60 | 84 |
| 61 std::vector<Workspace*> workspaces_; | 85 std::vector<Workspace*> workspaces_; |
| 62 | 86 |
| 87 gfx::Insets work_area_insets_; | |
| 88 | |
| 89 gfx::Size workspace_size_; | |
|
sky
2011/10/25 20:58:05
Document this.
| |
| 90 | |
| 91 // True if the workspace manager is in overview mode. | |
| 92 bool is_overview_; | |
| 93 | |
| 63 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | 94 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); |
| 64 }; | 95 }; |
| 65 | 96 |
| 66 } // namespace aura_shell | 97 } // namespace aura_shell |
| 67 | 98 |
| 68 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | 99 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ |
| OLD | NEW |