OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_WM_WORKSPACE_H_ | |
6 #define ASH_WM_WORKSPACE_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "base/basictypes.h" | |
12 #include "ui/gfx/rect.h" | |
13 | |
14 namespace aura { | |
15 class Window; | |
16 } | |
17 | |
18 namespace ash { | |
19 namespace internal { | |
20 | |
21 class WorkspaceManager; | |
22 | |
23 // A workspace contains a number of windows. The number of windows a Workspace | |
24 // may contain is dictated by the type. Typically only one workspace is visible | |
25 // at a time. The exception to that is when overview mode is active. | |
26 class ASH_EXPORT Workspace { | |
27 public: | |
28 // Type of workspace. The type of workspace dictates the types of windows the | |
29 // workspace can contain. | |
30 enum Type { | |
31 // The workspace holds a single maximized or full screen window. | |
32 TYPE_MAXIMIZED, | |
33 | |
34 // Workspace contains non-maximized windows. | |
35 TYPE_MANAGED, | |
36 }; | |
37 | |
38 Workspace(WorkspaceManager* manager, Type type); | |
39 virtual ~Workspace(); | |
40 | |
41 // Returns the type of workspace that can contain |window|. | |
42 static Type TypeForWindow(aura::Window* window); | |
43 | |
44 Type type() const { return type_; } | |
45 | |
46 // Returns true if this workspace has no windows. | |
47 bool is_empty() const { return windows_.empty(); } | |
48 size_t num_windows() const { return windows_.size(); } | |
49 const std::vector<aura::Window*>& windows() const { return windows_; } | |
50 | |
51 // Adds the |window| at the position after the window |after|. It | |
52 // inserts at the end if |after| is NULL. Return true if the | |
53 // |window| was successfully added to this workspace, or false if it | |
54 // failed. | |
55 bool AddWindowAfter(aura::Window* window, aura::Window* after); | |
56 | |
57 // Removes |window| from this workspace. | |
58 void RemoveWindow(aura::Window* window); | |
59 | |
60 // Return true if this workspace has |window|. | |
61 bool Contains(aura::Window* window) const; | |
62 | |
63 // Activates this workspace. | |
64 void Activate(); | |
65 | |
66 protected: | |
67 // Sets the bounds of the specified window. | |
68 void SetWindowBounds(aura::Window* window, const gfx::Rect& bounds); | |
69 | |
70 // Returns true if the given |window| can be added to this workspace. | |
71 virtual bool CanAdd(aura::Window* window) const = 0; | |
72 | |
73 // Invoked from AddWindowAfter(). | |
74 virtual void OnWindowAddedAfter(aura::Window* window, | |
75 aura::Window* after) = 0; | |
76 | |
77 // Invoked from RemoveWindow(). | |
78 virtual void OnWindowRemoved(aura::Window* window) = 0; | |
79 | |
80 private: | |
81 const Type type_; | |
82 | |
83 WorkspaceManager* workspace_manager_; | |
84 | |
85 // Windows in the workspace in layout order. | |
86 std::vector<aura::Window*> windows_; | |
87 | |
88 DISALLOW_COPY_AND_ASSIGN(Workspace); | |
89 }; | |
90 | |
91 typedef std::vector<Workspace*> Workspaces; | |
92 | |
93 } // namespace internal | |
94 } // namespace ash | |
95 | |
96 #endif // ASH_WM_WORKSPACE_H_ | |
OLD | NEW |