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_H_ | 5 #ifndef UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ |
| 6 #define UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ | 6 #define UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "ui/aura_shell/aura_shell_export.h" | 12 #include "ui/aura_shell/aura_shell_export.h" |
| 13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 class Window; | 16 class Window; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace aura_shell { | 19 namespace aura_shell { |
| 20 class WorkspaceManager; | 20 class WorkspaceManager; |
| 21 class WorkspaceTest; | 21 class WorkspaceTest; |
| 22 | 22 |
| 23 // A workspace is a partial area of the entire desktop that is visible to | 23 // A workspace is a partial area of the entire desktop (viewport) that |
| 24 // a user at a given time. The size of workspace is generally same as | 24 // is visible to a user at a given time. The size of workspace is |
|
sky
2011/10/25 20:58:05
'to a user' -> 'to the user'
'size of workspace' -
| |
| 25 // the size of the monitor, and the desktiop can have multiple workspaces. | 25 // generally same as the size of the monitor, and the desktiop can |
|
sky
2011/10/25 20:58:05
'generally same' -> 'generally the same'
desktiop
oshima
2011/10/25 23:37:23
Done.
| |
| 26 // One workspace can contains limited number of windows and | 26 // have multiple workspaces. |
| 27 // the workspace manager may create new workspace if there is | 27 // One workspace can contains limited number of windows and the |
|
sky
2011/10/25 20:58:05
Don't indent here.
'A worskpace contains a limited
oshima
2011/10/25 23:37:23
Done.
| |
| 28 // no room for new windowk. | 28 // workspace manager may create new workspace if there is no room for |
|
sky
2011/10/25 20:58:05
'may create new' -> 'may create a new'
'no room' -
oshima
2011/10/25 23:37:23
Done.
| |
| 29 // new windowk. | |
| 29 // | 30 // |
| 30 // TODO(oshima): Add a work area bounds for workspace. It will be used to | |
| 31 // limit the resize, layout and as bounds for a maximized window. | |
| 32 class AURA_SHELL_EXPORT Workspace { | 31 class AURA_SHELL_EXPORT Workspace { |
| 33 public: | 32 public: |
| 34 explicit Workspace(WorkspaceManager* manager); | 33 explicit Workspace(WorkspaceManager* manager); |
| 35 virtual ~Workspace(); | 34 virtual ~Workspace(); |
| 36 | 35 |
| 37 // Returns true if this workspace has no windows. | 36 // Returns true if this workspace has no windows. |
| 38 bool is_empty() const { return windows_.empty(); } | 37 bool is_empty() const { return windows_.empty(); } |
| 39 | 38 |
| 40 // Sets/gets bounds of this workspace. | 39 // Sets/gets bounds of this workspace. |
| 41 const gfx::Rect& bounds() { return bounds_; } | 40 const gfx::Rect& bounds() { return bounds_; } |
| 42 void SetBounds(const gfx::Rect& bounds); | 41 void SetBounds(const gfx::Rect& bounds); |
| 43 | 42 |
| 44 // Adds the |window| at the position after the window |after|. It | 43 // Adds the |window| at the position after the window |after|. It |
| 45 // inserts at the end if |after| is NULL. Return true if the | 44 // inserts at the end if |after| is NULL. Return true if the |
| 46 // |window| was successfully added to this workspace, or false if it | 45 // |window| was successfully added to this workspace, or false if it |
| 47 // failed. | 46 // failed. |
| 48 bool AddWindowAfter(aura::Window* window, aura::Window* after); | 47 bool AddWindowAfter(aura::Window* window, aura::Window* after); |
| 49 | 48 |
| 49 // Returns the work area bounds of this workspace in viewport | |
| 50 // coordinates. | |
| 51 gfx::Rect GetWorkAreaBounds() const; | |
| 52 | |
| 50 // Removes the |window| from this workspace. | 53 // Removes the |window| from this workspace. |
| 51 void RemoveWindow(aura::Window* window); | 54 void RemoveWindow(aura::Window* window); |
| 52 | 55 |
| 53 // Return true if this workspace has the |window|. | 56 // Return true if this workspace has the |window|. |
| 54 bool Contains(aura::Window* window) const; | 57 bool Contains(aura::Window* window) const; |
| 55 | 58 |
| 56 // Activates this workspace. | 59 // Activates this workspace. |
| 57 void Activate(); | 60 void Activate(); |
| 58 | 61 |
| 62 // Layout windows. |new_window| may be NULL. | |
| 63 void Layout(aura::Window* new_window); | |
|
sky
2011/10/25 20:58:05
Document what new_window is.
oshima
2011/10/25 23:37:23
Done.
| |
| 64 | |
| 59 private: | 65 private: |
| 60 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic); | 66 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic); |
| 61 | 67 |
| 62 // Returns the index in layout order of the |window| in this workspace. | 68 // Returns the index in layout order of the |window| in this workspace. |
| 63 int GetIndexOf(aura::Window* window) const; | 69 int GetIndexOf(aura::Window* window) const; |
| 64 | 70 |
| 65 // Returns true if the given |window| can be added to this workspace. | 71 // Returns true if the given |window| can be added to this workspace. |
| 66 bool CanAdd(aura::Window* window) const; | 72 bool CanAdd(aura::Window* window) const; |
| 67 | 73 |
| 74 // Moves |window| to the given point. It performs animation when | |
| 75 // |animate| is true. | |
| 76 void MoveWindowTo(aura::Window* window, | |
| 77 const gfx::Point& origin, | |
| 78 bool animate); | |
| 79 | |
| 68 WorkspaceManager* workspace_manager_; | 80 WorkspaceManager* workspace_manager_; |
| 69 | 81 |
| 70 gfx::Rect bounds_; | 82 gfx::Rect bounds_; |
| 71 | 83 |
| 72 // Windows in the workspace in layout order. | 84 // Windows in the workspace in layout order. |
| 73 std::vector<aura::Window*> windows_; | 85 std::vector<aura::Window*> windows_; |
| 74 | 86 |
| 75 DISALLOW_COPY_AND_ASSIGN(Workspace); | 87 DISALLOW_COPY_AND_ASSIGN(Workspace); |
| 76 }; | 88 }; |
| 77 | 89 |
| 78 typedef std::vector<Workspace*> Workspaces; | 90 typedef std::vector<Workspace*> Workspaces; |
| 79 | 91 |
| 80 } // namespace aura_shell | 92 } // namespace aura_shell |
| 81 | 93 |
| 82 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ | 94 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ |
| OLD | NEW |