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

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.
50 bool CanDrag(Panel* panel) const;
48 void StartDragging(Panel* panel); 51 void StartDragging(Panel* panel);
49 void Drag(int delta_x); 52 void Drag(int delta_x, int delta_y);
50 void EndDragging(bool cancelled); 53 void EndDragging(bool cancelled);
51 54
52 // Invoked when a panel's expansion state changes. 55 // Invoked when a panel's expansion state changes.
53 void OnPanelExpansionStateChanged(Panel* panel); 56 void OnPanelExpansionStateChanged(Panel* panel);
54 57
55 // Invoked when the preferred window size of the given panel might need to 58 // Invoked when the preferred window size of the given panel might need to
56 // get changed. 59 // get changed.
57 void OnPreferredWindowSizeChanged( 60 void OnPreferredWindowSizeChanged(
58 Panel* panel, const gfx::Size& preferred_window_size); 61 Panel* panel, const gfx::Size& preferred_window_size);
59 62
(...skipping 10 matching lines...) Expand all
70 73
71 // Returns the next browser window which could be either panel window or 74 // 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. 75 // tabbed window, to switch to if the given panel is going to be deactivated.
73 // Returns NULL if such window cannot be found. 76 // Returns NULL if such window cannot be found.
74 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; 77 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const;
75 78
76 int num_panels() const; 79 int num_panels() const;
77 int StartingRightPosition() const; 80 int StartingRightPosition() const;
78 std::vector<Panel*> panels() const; 81 std::vector<Panel*> panels() const;
79 82
83 PanelDragController* drag_controller() const {
84 return drag_controller_.get();
85 }
86
80 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { 87 AutoHidingDesktopBar* auto_hiding_desktop_bar() const {
81 return auto_hiding_desktop_bar_; 88 return auto_hiding_desktop_bar_;
82 } 89 }
83 90
84 PanelMouseWatcher* mouse_watcher() const { 91 PanelMouseWatcher* mouse_watcher() const {
85 return panel_mouse_watcher_.get(); 92 return panel_mouse_watcher_.get();
86 } 93 }
87 94
95 DetachedPanelStrip* detached_strip() const {
96 return detached_strip_.get();
97 }
98
88 DockedPanelStrip* docked_strip() const { 99 DockedPanelStrip* docked_strip() const {
89 return docked_strip_.get(); 100 return docked_strip_.get();
90 } 101 }
91 102
92 bool is_full_screen() const { return is_full_screen_; } 103 bool is_full_screen() const { return is_full_screen_; }
93 OverflowPanelStrip* overflow_strip() const { 104 OverflowPanelStrip* overflow_strip() const {
94 return overflow_strip_.get(); 105 return overflow_strip_.get();
95 } 106 }
96 107
97 // Reduces time interval in tests to shorten test run time. 108 // Reduces time interval in tests to shorten test run time.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 165
155 // Tests if the current active app is in full screen mode. 166 // Tests if the current active app is in full screen mode.
156 void CheckFullScreenMode(); 167 void CheckFullScreenMode();
157 168
158 // Tests may want to use a mock panel mouse watcher. 169 // Tests may want to use a mock panel mouse watcher.
159 void SetMouseWatcher(PanelMouseWatcher* watcher); 170 void SetMouseWatcher(PanelMouseWatcher* watcher);
160 171
161 // Tests may want to shorten time intervals to reduce running time. 172 // Tests may want to shorten time intervals to reduce running time.
162 static bool shorten_time_intervals_; 173 static bool shorten_time_intervals_;
163 174
175 scoped_ptr<DetachedPanelStrip> detached_strip_;
164 scoped_ptr<DockedPanelStrip> docked_strip_; 176 scoped_ptr<DockedPanelStrip> docked_strip_;
165 scoped_ptr<OverflowPanelStrip> overflow_strip_; 177 scoped_ptr<OverflowPanelStrip> overflow_strip_;
166 178
179 scoped_ptr<PanelDragController> drag_controller_;
180
167 // Use a mouse watcher to know when to bring up titlebars to "peek" at 181 // 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 182 // minimized panels. Mouse movement is only tracked when there is a minimized
169 // panel. 183 // panel.
170 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; 184 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_;
171 185
172 // The maximum work area avaialble. This area does not include the area taken 186 // The maximum work area avaialble. This area does not include the area taken
173 // by the always-visible (non-auto-hiding) desktop bars. 187 // by the always-visible (non-auto-hiding) desktop bars.
174 gfx::Rect work_area_; 188 gfx::Rect work_area_;
175 189
176 // The useable work area for computing the panel bounds. This area excludes 190 // 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. 203 // Timer used to track if the current active app is in full screen mode.
190 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; 204 base::RepeatingTimer<PanelManager> full_screen_mode_timer_;
191 205
192 // True if current active app is in full screen mode. 206 // True if current active app is in full screen mode.
193 bool is_full_screen_; 207 bool is_full_screen_;
194 208
195 DISALLOW_COPY_AND_ASSIGN(PanelManager); 209 DISALLOW_COPY_AND_ASSIGN(PanelManager);
196 }; 210 };
197 211
198 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 212 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698