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