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

Side by Side Diff: chrome/browser/ui/panels/panel_manager.h

Issue 11669018: Support dragging panels to stack and snap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CrOS build for relanding Created 7 years, 11 months 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) 2012 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
7 7
8 #include <list>
8 #include <vector> 9 #include <vector>
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/panels/display_settings_provider.h" 13 #include "chrome/browser/ui/panels/display_settings_provider.h"
13 #include "chrome/browser/ui/panels/panel.h" 14 #include "chrome/browser/ui/panels/panel.h"
14 #include "chrome/browser/ui/panels/panel_collection.h" 15 #include "chrome/browser/ui/panels/panel_collection.h"
15 #include "chrome/browser/ui/panels/panel_constants.h" 16 #include "chrome/browser/ui/panels/panel_constants.h"
16 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
17 18
18 class DetachedPanelCollection; 19 class DetachedPanelCollection;
19 class DockedPanelCollection; 20 class DockedPanelCollection;
20 class GURL; 21 class GURL;
21 class PanelDragController; 22 class PanelDragController;
22 class PanelResizeController; 23 class PanelResizeController;
23 class PanelMouseWatcher; 24 class PanelMouseWatcher;
25 class StackedPanelCollection;
24 26
25 // This class manages a set of panels. 27 // This class manages a set of panels.
26 class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver, 28 class PanelManager : public DisplaySettingsProvider::DisplayAreaObserver,
27 public DisplaySettingsProvider::FullScreenObserver { 29 public DisplaySettingsProvider::FullScreenObserver {
28 public: 30 public:
31 typedef std::list<StackedPanelCollection*> Stacks;
32
29 enum CreateMode { 33 enum CreateMode {
30 CREATE_AS_DOCKED, // Creates a docked panel. The default. 34 CREATE_AS_DOCKED, // Creates a docked panel. The default.
31 CREATE_AS_DETACHED // Creates a detached panel. 35 CREATE_AS_DETACHED // Creates a detached panel.
32 }; 36 };
33 37
34 // Returns a single instance. 38 // Returns a single instance.
35 static PanelManager* GetInstance(); 39 static PanelManager* GetInstance();
36 40
37 // Returns true if panels should be used for the extension. 41 // Returns true if panels should be used for the extension.
38 static bool ShouldUsePanels(const std::string& extension_id); 42 static bool ShouldUsePanels(const std::string& extension_id);
(...skipping 17 matching lines...) Expand all
56 const GURL& url, 60 const GURL& url,
57 const gfx::Rect& requested_bounds, 61 const gfx::Rect& requested_bounds,
58 CreateMode mode); 62 CreateMode mode);
59 63
60 // Close all panels (asynchronous). Panels will be removed after closing. 64 // Close all panels (asynchronous). Panels will be removed after closing.
61 void CloseAll(); 65 void CloseAll();
62 66
63 // Asynchronous confirmation of panel having been closed. 67 // Asynchronous confirmation of panel having been closed.
64 void OnPanelClosed(Panel* panel); 68 void OnPanelClosed(Panel* panel);
65 69
70 // Creates a StackedPanelCollection and returns it.
71 StackedPanelCollection* CreateStack();
72
73 // Deletes |stack|. The stack must be empty at the time of deletion.
74 void RemoveStack(StackedPanelCollection* stack);
75
66 // Returns the maximum size that panel can be auto-resized or resized by the 76 // Returns the maximum size that panel can be auto-resized or resized by the
67 // API. 77 // API.
68 int GetMaxPanelWidth() const; 78 int GetMaxPanelWidth() const;
69 int GetMaxPanelHeight() const; 79 int GetMaxPanelHeight() const;
70 80
71 // Drags the given panel. 81 // Drags the given panel.
72 // |mouse_location| is in screen coordinate system. 82 // |mouse_location| is in screen coordinate system.
73 void StartDragging(Panel* panel, const gfx::Point& mouse_location); 83 void StartDragging(Panel* panel, const gfx::Point& mouse_location);
74 void Drag(const gfx::Point& mouse_location); 84 void Drag(const gfx::Point& mouse_location);
75 void EndDragging(bool cancelled); 85 void EndDragging(bool cancelled);
(...skipping 13 matching lines...) Expand all
89 PanelCollection* target_collection, 99 PanelCollection* target_collection,
90 PanelCollection::PositioningMask positioning_mask); 100 PanelCollection::PositioningMask positioning_mask);
91 101
92 // Returns true if we should bring up the titlebars, given the current mouse 102 // Returns true if we should bring up the titlebars, given the current mouse
93 // point. 103 // point.
94 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; 104 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const;
95 105
96 // Brings up or down the titlebars for all minimized panels. 106 // Brings up or down the titlebars for all minimized panels.
97 void BringUpOrDownTitlebars(bool bring_up); 107 void BringUpOrDownTitlebars(bool bring_up);
98 108
109 std::vector<Panel*> GetDetachedAndStackedPanels() const;
110
99 int num_panels() const; 111 int num_panels() const;
100 std::vector<Panel*> panels() const; 112 std::vector<Panel*> panels() const;
101 113
114 const Stacks& stacks() const { return stacks_; }
115 int num_stacks() const { return stacks_.size(); }
116
102 PanelDragController* drag_controller() const { 117 PanelDragController* drag_controller() const {
103 return drag_controller_.get(); 118 return drag_controller_.get();
104 } 119 }
105 120
106 #ifdef UNIT_TEST 121 #ifdef UNIT_TEST
107 PanelResizeController* resize_controller() const { 122 PanelResizeController* resize_controller() const {
108 return resize_controller_.get(); 123 return resize_controller_.get();
109 } 124 }
110 #endif 125 #endif
111 126
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 virtual void OnFullScreenModeChanged(bool is_full_screen) OVERRIDE; 191 virtual void OnFullScreenModeChanged(bool is_full_screen) OVERRIDE;
177 192
178 // Tests may want to use a mock panel mouse watcher. 193 // Tests may want to use a mock panel mouse watcher.
179 void SetMouseWatcher(PanelMouseWatcher* watcher); 194 void SetMouseWatcher(PanelMouseWatcher* watcher);
180 195
181 // Tests may want to shorten time intervals to reduce running time. 196 // Tests may want to shorten time intervals to reduce running time.
182 static bool shorten_time_intervals_; 197 static bool shorten_time_intervals_;
183 198
184 scoped_ptr<DetachedPanelCollection> detached_collection_; 199 scoped_ptr<DetachedPanelCollection> detached_collection_;
185 scoped_ptr<DockedPanelCollection> docked_collection_; 200 scoped_ptr<DockedPanelCollection> docked_collection_;
201 Stacks stacks_;
186 202
187 scoped_ptr<PanelDragController> drag_controller_; 203 scoped_ptr<PanelDragController> drag_controller_;
188 scoped_ptr<PanelResizeController> resize_controller_; 204 scoped_ptr<PanelResizeController> resize_controller_;
189 205
190 // Use a mouse watcher to know when to bring up titlebars to "peek" at 206 // Use a mouse watcher to know when to bring up titlebars to "peek" at
191 // minimized panels. Mouse movement is only tracked when there is a minimized 207 // minimized panels. Mouse movement is only tracked when there is a minimized
192 // panel. 208 // panel.
193 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; 209 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_;
194 210
195 scoped_ptr<DisplaySettingsProvider> display_settings_provider_; 211 scoped_ptr<DisplaySettingsProvider> display_settings_provider_;
196 212
197 gfx::Rect display_area_; 213 gfx::Rect display_area_;
198 214
199 // Whether or not bounds will be updated when the preferred content size is 215 // Whether or not bounds will be updated when the preferred content size is
200 // changed. The testing code could set this flag to false so that other tests 216 // changed. The testing code could set this flag to false so that other tests
201 // will not be affected. 217 // will not be affected.
202 bool auto_sizing_enabled_; 218 bool auto_sizing_enabled_;
203 219
204 DISALLOW_COPY_AND_ASSIGN(PanelManager); 220 DISALLOW_COPY_AND_ASSIGN(PanelManager);
205 }; 221 };
206 222
207 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 223 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_drag_controller.cc ('k') | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698