OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | |
6 #define UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/observer_list.h" | |
13 #include "ui/aura_shell/aura_shell_export.h" | |
14 #include "ui/gfx/insets.h" | |
15 #include "ui/gfx/size.h" | |
16 | |
17 namespace aura { | |
18 class Window; | |
19 } | |
20 | |
21 namespace gfx { | |
22 class Point; | |
23 class Rect; | |
24 } | |
25 | |
26 namespace aura_shell { | |
27 namespace internal { | |
28 class Workspace; | |
29 class WorkspaceObserver; | |
30 | |
31 // WorkspaceManager manages multiple workspaces in the desktop. | |
32 class AURA_SHELL_EXPORT WorkspaceManager { | |
33 public: | |
34 explicit WorkspaceManager(aura::Window* viewport); | |
35 virtual ~WorkspaceManager(); | |
36 | |
37 // Returns the Window this WorkspaceManager controls. | |
38 aura::Window* contents_view() { return contents_view_; } | |
39 | |
40 // Create new workspace. Workspace objects are managed by | |
41 // this WorkspaceManager. Deleting workspace will automatically | |
42 // remove the workspace from the workspace_manager. | |
43 Workspace* CreateWorkspace(); | |
44 | |
45 // Returns the active workspace. | |
46 Workspace* GetActiveWorkspace() const; | |
47 | |
48 // Returns the workspace that contanis the |window|. | |
49 Workspace* FindBy(aura::Window* window) const; | |
50 | |
51 // Returns the window for rotate operation based on the |location|. | |
52 aura::Window* FindRotateWindowForLocation(const gfx::Point& location); | |
53 | |
54 // Sets the bounds of all workspaces. | |
55 void LayoutWorkspaces(); | |
56 | |
57 // Returns the bounds in which a window can be moved/resized. | |
58 gfx::Rect GetDragAreaBounds(); | |
59 | |
60 // Turn on/off overview mode. | |
61 void SetOverview(bool overview); | |
62 bool is_overview() const { return is_overview_; } | |
63 | |
64 // Rotate windows by moving |source| window to the position of |target|. | |
65 void RotateWindows(aura::Window* source, aura::Window* target); | |
66 | |
67 // Sets the size of a single workspace (all workspaces have the same size). | |
68 void SetWorkspaceSize(const gfx::Size& workspace_size); | |
69 | |
70 // Adds/Removes workspace observer. | |
71 void AddObserver(WorkspaceObserver* observer); | |
72 void RemoveObserver(WorkspaceObserver* observer); | |
73 | |
74 // Returns true if this workspace manager is laying out windows. | |
75 // When true, LayoutManager must give windows their requested bounds. | |
76 bool layout_in_progress() const { return layout_in_progress_; } | |
77 | |
78 // Sets the |layout_in_progress_| flag. | |
79 void set_layout_in_progress(bool layout_in_progress) { | |
80 layout_in_progress_ = layout_in_progress; | |
81 } | |
82 | |
83 // Sets/Returns the ignored window that the workspace manager does not | |
84 // set bounds on. | |
85 void set_ignored_window(aura::Window* ignored_window) { | |
86 ignored_window_ = ignored_window; | |
87 } | |
88 aura::Window* ignored_window() { return ignored_window_; } | |
89 | |
90 private: | |
91 friend class Workspace; | |
92 | |
93 void AddWorkspace(Workspace* workspace); | |
94 void RemoveWorkspace(Workspace* workspace); | |
95 | |
96 // Sets the active workspace. | |
97 void SetActiveWorkspace(Workspace* workspace); | |
98 | |
99 // Returns the bounds of the work are given |workspace_bounds|. | |
100 gfx::Rect GetWorkAreaBounds(const gfx::Rect& workspace_bounds); | |
101 | |
102 // Returns the index of the workspace that contains the |window|. | |
103 int GetWorkspaceIndexContaining(aura::Window* window) const; | |
104 | |
105 // Update contents_view size and move the viewport to the active workspace. | |
106 void UpdateContentsView(); | |
107 | |
108 aura::Window* contents_view_; | |
109 | |
110 Workspace* active_workspace_; | |
111 | |
112 std::vector<Workspace*> workspaces_; | |
113 | |
114 // The size of a single workspace. This is generally the same as the size of | |
115 // monitor. | |
116 gfx::Size workspace_size_; | |
117 | |
118 // True if the workspace manager is in overview mode. | |
119 bool is_overview_; | |
120 | |
121 // True if this layout manager is laying out windows. | |
122 bool layout_in_progress_; | |
123 | |
124 // The window that WorkspaceManager does not set the bounds on. | |
125 aura::Window* ignored_window_; | |
126 | |
127 ObserverList<WorkspaceObserver> observers_; | |
128 | |
129 DISALLOW_COPY_AND_ASSIGN(WorkspaceManager); | |
130 }; | |
131 | |
132 } // namespace internal | |
133 } // namespace aura_shell | |
134 | |
135 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_MANAGER_H_ | |
OLD | NEW |