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

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

Issue 9403035: Refactor intra-strip panel drags by introducing PanelDragController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 years, 10 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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" 14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h"
15 #include "chrome/browser/ui/panels/panel.h" 15 #include "chrome/browser/ui/panels/panel.h"
16 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
17 17
18 class Browser; 18 class Browser;
19 class DetachedPanelStrip;
20 class DockedPanelStrip;
21 class OverflowPanelStrip;
22 class PanelDragController;
19 class PanelMouseWatcher; 23 class PanelMouseWatcher;
20 class OverflowPanelStrip;
21 class DockedPanelStrip;
22 24
23 // This class manages a set of panels. 25 // This class manages a set of panels.
24 class PanelManager : public AutoHidingDesktopBar::Observer { 26 class PanelManager : public AutoHidingDesktopBar::Observer {
25 public: 27 public:
26 // Returns a single instance. 28 // Returns a single instance.
27 static PanelManager* GetInstance(); 29 static PanelManager* GetInstance();
28 30
29 // Returns true if panels should be used for the extension. 31 // Returns true if panels should be used for the extension.
30 static bool ShouldUsePanels(const std::string& extension_id); 32 static bool ShouldUsePanels(const std::string& extension_id);
31 33
32 // Called when the display is changed, i.e. work area is updated. 34 // Called when the display is changed, i.e. work area is updated.
33 void OnDisplayChanged(); 35 void OnDisplayChanged();
34 36
35 // Creates a panel and returns it. The panel might be queued for display 37 // Creates a panel and returns it. The panel might be queued for display
36 // later. 38 // later.
37 Panel* CreatePanel(Browser* browser); 39 Panel* CreatePanel(Browser* browser);
38 40
39 void Remove(Panel* panel); 41 void Remove(Panel* panel);
40 42
41 // Close all panels (asynchronous). Panels will be removed after closing. 43 // Close all panels (asynchronous). Panels will be removed after closing.
42 void CloseAll(); 44 void CloseAll();
43 45
44 // Asynchronous confirmation of panel having been removed. 46 // Asynchronous confirmation of panel having been removed.
45 void OnPanelRemoved(Panel* panel); 47 void OnPanelRemoved(Panel* panel);
46 48
47 // Drags the given panel. 49 // Drags the given panel.
48 void StartDragging(Panel* panel); 50 void StartDragging(Panel* panel);
49 void Drag(int delta_x); 51 void Drag(int delta_x, int delta_y);
50 void EndDragging(bool cancelled); 52 void EndDragging(bool cancelled);
51 53
52 // Invoked when a panel's expansion state changes. 54 // Invoked when a panel's expansion state changes.
53 void OnPanelExpansionStateChanged(Panel* panel); 55 void OnPanelExpansionStateChanged(Panel* panel);
54 56
55 // Invoked when the preferred window size of the given panel might need to 57 // Invoked when the preferred window size of the given panel might need to
56 // get changed. 58 // get changed.
57 void OnPreferredWindowSizeChanged( 59 void OnPreferredWindowSizeChanged(
58 Panel* panel, const gfx::Size& preferred_window_size); 60 Panel* panel, const gfx::Size& preferred_window_size);
59 61
(...skipping 10 matching lines...) Expand all
70 72
71 // Returns the next browser window which could be either panel window or 73 // Returns the next browser window which could be either panel window or
72 // tabbed window, to switch to if the given panel is going to be deactivated. 74 // tabbed window, to switch to if the given panel is going to be deactivated.
73 // Returns NULL if such window cannot be found. 75 // Returns NULL if such window cannot be found.
74 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; 76 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const;
75 77
76 int num_panels() const; 78 int num_panels() const;
77 int StartingRightPosition() const; 79 int StartingRightPosition() const;
78 std::vector<Panel*> panels() const; 80 std::vector<Panel*> panels() const;
79 81
82 PanelDragController* drag_controller() const {
83 return drag_controller_.get();
84 }
85
80 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { 86 AutoHidingDesktopBar* auto_hiding_desktop_bar() const {
81 return auto_hiding_desktop_bar_; 87 return auto_hiding_desktop_bar_;
82 } 88 }
83 89
84 PanelMouseWatcher* mouse_watcher() const { 90 PanelMouseWatcher* mouse_watcher() const {
85 return panel_mouse_watcher_.get(); 91 return panel_mouse_watcher_.get();
86 } 92 }
87 93
94 DetachedPanelStrip* detached_strip() const {
95 return detached_strip_.get();
96 }
97
88 DockedPanelStrip* docked_strip() const { 98 DockedPanelStrip* docked_strip() const {
89 return docked_strip_.get(); 99 return docked_strip_.get();
90 } 100 }
91 101
92 bool is_full_screen() const { return is_full_screen_; } 102 bool is_full_screen() const { return is_full_screen_; }
93 OverflowPanelStrip* overflow_strip() const { 103 OverflowPanelStrip* overflow_strip() const {
94 return overflow_strip_.get(); 104 return overflow_strip_.get();
95 } 105 }
96 106
97 // Reduces time interval in tests to shorten test run time. 107 // Reduces time interval in tests to shorten test run time.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 164
155 // Tests if the current active app is in full screen mode. 165 // Tests if the current active app is in full screen mode.
156 void CheckFullScreenMode(); 166 void CheckFullScreenMode();
157 167
158 // Tests may want to use a mock panel mouse watcher. 168 // Tests may want to use a mock panel mouse watcher.
159 void SetMouseWatcher(PanelMouseWatcher* watcher); 169 void SetMouseWatcher(PanelMouseWatcher* watcher);
160 170
161 // Tests may want to shorten time intervals to reduce running time. 171 // Tests may want to shorten time intervals to reduce running time.
162 static bool shorten_time_intervals_; 172 static bool shorten_time_intervals_;
163 173
174 scoped_ptr<DetachedPanelStrip> detached_strip_;
164 scoped_ptr<DockedPanelStrip> docked_strip_; 175 scoped_ptr<DockedPanelStrip> docked_strip_;
165 scoped_ptr<OverflowPanelStrip> overflow_strip_; 176 scoped_ptr<OverflowPanelStrip> overflow_strip_;
166 177
178 scoped_ptr<PanelDragController> drag_controller_;
179
167 // Use a mouse watcher to know when to bring up titlebars to "peek" at 180 // Use a mouse watcher to know when to bring up titlebars to "peek" at
168 // minimized panels. Mouse movement is only tracked when there is a minimized 181 // minimized panels. Mouse movement is only tracked when there is a minimized
169 // panel. 182 // panel.
170 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; 183 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_;
171 184
172 // The maximum work area avaialble. This area does not include the area taken 185 // The maximum work area avaialble. This area does not include the area taken
173 // by the always-visible (non-auto-hiding) desktop bars. 186 // by the always-visible (non-auto-hiding) desktop bars.
174 gfx::Rect work_area_; 187 gfx::Rect work_area_;
175 188
176 // The useable work area for computing the panel bounds. This area excludes 189 // The useable work area for computing the panel bounds. This area excludes
(...skipping 12 matching lines...) Expand all
189 // Timer used to track if the current active app is in full screen mode. 202 // Timer used to track if the current active app is in full screen mode.
190 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; 203 base::RepeatingTimer<PanelManager> full_screen_mode_timer_;
191 204
192 // True if current active app is in full screen mode. 205 // True if current active app is in full screen mode.
193 bool is_full_screen_; 206 bool is_full_screen_;
194 207
195 DISALLOW_COPY_AND_ASSIGN(PanelManager); 208 DISALLOW_COPY_AND_ASSIGN(PanelManager);
196 }; 209 };
197 210
198 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 211 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698