Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ui/aura_shell/workspace/workspace.h

Issue 8391035: Drag and rotate windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rotate windows Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 // generally the same as the size of the monitor, and the desktop can 25 // generally the same as the size of the monitor, and the desktop can
26 // have multiple workspaces. 26 // have multiple workspaces.
27 // A workspace contains a limited number of windows and the workspace 27 // A workspace contains a limited number of windows and the workspace
28 // manager may create a new workspace if there is not enough room for 28 // manager may create a new workspace if there is not enough room for
29 // a new window. 29 // a new window.
30 class AURA_SHELL_EXPORT Workspace { 30 class AURA_SHELL_EXPORT Workspace {
31 public: 31 public:
32 explicit Workspace(WorkspaceManager* manager); 32 explicit Workspace(WorkspaceManager* manager);
33 virtual ~Workspace(); 33 virtual ~Workspace();
34 34
35 // Specifies the direction to shift windows in |ShiftWindows()|.
36 enum ShiftDirection {
37 SHIFT_TO_RIGHT,
38 SHIFT_TO_LEFT
39 };
40
35 // Returns true if this workspace has no windows. 41 // Returns true if this workspace has no windows.
36 bool is_empty() const { return windows_.empty(); } 42 bool is_empty() const { return windows_.empty(); }
37 43
38 // Sets/gets bounds of this workspace. 44 // Sets/gets bounds of this workspace.
39 const gfx::Rect& bounds() { return bounds_; } 45 const gfx::Rect& bounds() { return bounds_; }
40 void SetBounds(const gfx::Rect& bounds); 46 void SetBounds(const gfx::Rect& bounds);
41 47
42 // Returns the work area bounds of this workspace in viewport 48 // Returns the work area bounds of this workspace in viewport
43 // coordinates. 49 // coordinates.
44 gfx::Rect GetWorkAreaBounds() const; 50 gfx::Rect GetWorkAreaBounds() const;
45 51
46 // Adds the |window| at the position after the window |after|. It 52 // Adds the |window| at the position after the window |after|. It
47 // inserts at the end if |after| is NULL. Return true if the 53 // inserts at the end if |after| is NULL. Return true if the
48 // |window| was successfully added to this workspace, or false if it 54 // |window| was successfully added to this workspace, or false if it
49 // failed. 55 // failed.
50 bool AddWindowAfter(aura::Window* window, aura::Window* after); 56 bool AddWindowAfter(aura::Window* window, aura::Window* after);
51 57
52 // Removes the |window| from this workspace. 58 // Removes the |window| from this workspace.
53 void RemoveWindow(aura::Window* window); 59 void RemoveWindow(aura::Window* window);
54 60
55 // Return true if this workspace has the |window|. 61 // Return true if this workspace has the |window|.
56 bool Contains(aura::Window* window) const; 62 bool Contains(aura::Window* window) const;
57 63
64 // Returns a window to rotate to based on the |position|.
sky 2011/10/27 19:46:41 remove 'the'
oshima 2011/10/27 20:25:43 Done.
65 aura::Window* FindRotateWindowForLocation(const gfx::Point& position);
66
67 // Rotates the windows by removing |source| and inserting it to the
68 // position that |target| was in. It re-layouts windows except for |source|.
69 void RotateWindows(aura::Window* source, aura::Window* target);
70
71 // Shift the windows in the workspace by inserting |window| until
72 // it reaches |until|. |insert| is inserted at the beginning if
73 // the |direction| is |SHIFT_TO_RIGHT|, or at the end if the |direction|
74 // is |SHIFT_TO_LEFT|. It returns the window that is overflowed by shifting,
75 // or NULL if shifting stopped at |until|.
76 aura::Window* ShiftWindows(aura::Window* insert,
77 aura::Window* until,
78 ShiftDirection direction);
79
58 // Activates this workspace. 80 // Activates this workspace.
59 void Activate(); 81 void Activate();
60 82
61 // Layout windows. Moving animation is applied to all windows except 83 // Layout windows. The workspace doesn't set bounds on the |ignore| if it's
sky 2011/10/27 19:46:41 'the ignore' -> 'ignore' same with next line
oshima 2011/10/27 20:25:43 removed all "the" before ||
62 // for the window specified by |no_animation|. 84 // given. It still uses the |ignore| window's bounds to calculate
63 void Layout(aura::Window* no_animation); 85 // bounds for other windows. Moving animation is applied to all
86 // windows except for the window specified by |no_animation| and |ignore|.
87 void Layout(aura::Window* ignore, aura::Window* no_animation);
64 88
65 private: 89 private:
66 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic); 90 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, WorkspaceBasic);
91 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, RotateWindows);
92 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, ShiftWindowsSingle);
93 FRIEND_TEST_ALL_PREFIXES(WorkspaceTest, ShiftWindowsMultiple);
94 FRIEND_TEST_ALL_PREFIXES(WorkspaceManagerTest, RotateWindows);
67 95
68 // Returns the index in layout order of the |window| in this workspace. 96 // Returns the index in layout order of the |window| in this workspace.
69 int GetIndexOf(aura::Window* window) const; 97 int GetIndexOf(aura::Window* window) const;
70 98
71 // Returns true if the given |window| can be added to this workspace. 99 // Returns true if the given |window| can be added to this workspace.
72 bool CanAdd(aura::Window* window) const; 100 bool CanAdd(aura::Window* window) const;
73 101
74 // Moves |window| to the given point. It performs animation when 102 // Moves |window| to the given point. It performs animation when
75 // |animate| is true. 103 // |animate| is true.
76 void MoveWindowTo(aura::Window* window, 104 void MoveWindowTo(aura::Window* window,
77 const gfx::Point& origin, 105 const gfx::Point& origin,
78 bool animate); 106 bool animate);
79 107
108 // Returns the sum of all window's width.
109 int GetTotalWindowsWidth() const;
110
111 // Test only: Changes how may windows workspace can haven.
sky 2011/10/27 19:46:41 haven -> have
oshima 2011/10/27 20:25:43 Done.
112 // Returns the current value so that it can be reverted back to
113 // original value.
114 static size_t SetMaxWindowsCount(size_t max);
115
80 WorkspaceManager* workspace_manager_; 116 WorkspaceManager* workspace_manager_;
81 117
82 gfx::Rect bounds_; 118 gfx::Rect bounds_;
83 119
84 // Windows in the workspace in layout order. 120 // Windows in the workspace in layout order.
85 std::vector<aura::Window*> windows_; 121 std::vector<aura::Window*> windows_;
86 122
87 DISALLOW_COPY_AND_ASSIGN(Workspace); 123 DISALLOW_COPY_AND_ASSIGN(Workspace);
88 }; 124 };
89 125
90 typedef std::vector<Workspace*> Workspaces; 126 typedef std::vector<Workspace*> Workspaces;
91 127
92 } // namespace aura_shell 128 } // namespace aura_shell
93 129
94 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_ 130 #endif // UI_AURA_SHELL_WORKSPACE_WORKSPACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698