| 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 the user at a given time. The size of the workspace is |
| 25 // the size of the monitor, and the desktiop can have multiple workspaces. | 25 // generally the same as the size of the monitor, and the desktop can |
| 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 // A workspace contains a limited number of windows and the workspace |
| 28 // no room for new windowk. | 28 // manager may create a new workspace if there is not enough room for |
| 29 // | 29 // a new window. |
| 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 { | 30 class AURA_SHELL_EXPORT Workspace { |
| 33 public: | 31 public: |
| 34 explicit Workspace(WorkspaceManager* manager); | 32 explicit Workspace(WorkspaceManager* manager); |
| 35 virtual ~Workspace(); | 33 virtual ~Workspace(); |
| 36 | 34 |
| 37 // Returns true if this workspace has no windows. | 35 // Returns true if this workspace has no windows. |
| 38 bool is_empty() const { return windows_.empty(); } | 36 bool is_empty() const { return windows_.empty(); } |
| 39 | 37 |
| 40 // Sets/gets bounds of this workspace. | 38 // Sets/gets bounds of this workspace. |
| 41 const gfx::Rect& bounds() { return bounds_; } | 39 const gfx::Rect& bounds() { return bounds_; } |
| 42 void SetBounds(const gfx::Rect& bounds); | 40 void SetBounds(const gfx::Rect& bounds); |
| 43 | 41 |
| 42 // Returns the work area bounds of this workspace in viewport |
| 43 // coordinates. |
| 44 gfx::Rect GetWorkAreaBounds() const; |
| 45 |
| 44 // Adds the |window| at the position after the window |after|. It | 46 // Adds the |window| at the position after the window |after|. It |
| 45 // inserts at the end if |after| is NULL. Return true if the | 47 // inserts at the end if |after| is NULL. Return true if the |
| 46 // |window| was successfully added to this workspace, or false if it | 48 // |window| was successfully added to this workspace, or false if it |
| 47 // failed. | 49 // failed. |
| 48 bool AddWindowAfter(aura::Window* window, aura::Window* after); | 50 bool AddWindowAfter(aura::Window* window, aura::Window* after); |
| 49 | 51 |
| 50 // Removes the |window| from this workspace. | 52 // Removes the |window| from this workspace. |
| 51 void RemoveWindow(aura::Window* window); | 53 void RemoveWindow(aura::Window* window); |
| 52 | 54 |
| 53 // Return true if this workspace has the |window|. | 55 // Return true if this workspace has the |window|. |
| 54 bool Contains(aura::Window* window) const; | 56 bool Contains(aura::Window* window) const; |
| 55 | 57 |
| 56 // Activates this workspace. | 58 // Activates this workspace. |
| 57 void Activate(); | 59 void Activate(); |
| 58 | 60 |
| 61 // Layout windows. Moving animation is applied to all windows except |
| 62 // for the window specified by |no_animation|. |
| 63 void Layout(aura::Window* no_animation); |
| 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 |