OLD | NEW |
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 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 "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" | 13 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" |
14 #include "chrome/browser/ui/panels/panel.h" | 14 #include "chrome/browser/ui/panels/panel.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
17 // TODO(jennb): Clean up by removing functions below that cause this | 17 // TODO(jennb): Clean up by removing functions below that cause this |
18 // to be required. | 18 // to be required. |
19 #ifdef UNIT_TEST | 19 #ifdef UNIT_TEST |
20 #include "chrome/browser/ui/panels/panel_strip.h" | 20 #include "chrome/browser/ui/panels/panel_strip.h" |
21 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 21 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
22 #endif | 22 #endif |
23 | 23 |
24 class Browser; | 24 class Browser; |
25 class PanelMouseWatcher; | 25 class PanelMouseWatcher; |
| 26 class PanelOverflowStrip; |
26 class PanelStrip; | 27 class PanelStrip; |
27 | 28 |
28 // This class manages a set of panels. | 29 // This class manages a set of panels. |
29 class PanelManager : public AutoHidingDesktopBar::Observer { | 30 class PanelManager : public AutoHidingDesktopBar::Observer { |
30 public: | 31 public: |
31 typedef std::vector<Panel*> Panels; | 32 typedef std::vector<Panel*> Panels; |
32 | 33 |
33 // Returns a single instance. | 34 // Returns a single instance. |
34 static PanelManager* GetInstance(); | 35 static PanelManager* GetInstance(); |
35 | 36 |
36 // Called when the display is changed, i.e. work area is updated. | 37 // Called when the display is changed, i.e. work area is updated. |
37 void OnDisplayChanged(); | 38 void OnDisplayChanged(); |
38 | 39 |
39 // Creates a panel and returns it. The panel might be queued for display | 40 // Creates a panel and returns it. The panel might be queued for display |
40 // later. | 41 // later. |
41 Panel* CreatePanel(Browser* browser); | 42 Panel* CreatePanel(Browser* browser); |
42 | 43 |
43 void Remove(Panel* panel); | 44 void Remove(Panel* panel); |
44 void RemoveAll(); | 45 void RemoveAll(); |
45 | 46 |
46 // Asynchronous confirmation of panel having been removed. | 47 // Asynchronous confirmation of panel having been removed. |
47 void OnPanelRemoved(Panel* panel); | 48 void OnPanelRemoved(Panel* panel); |
48 | 49 |
49 // Drags the given panel. | 50 // Drags the given panel. |
50 void StartDragging(Panel* panel); | 51 void StartDragging(Panel* panel); |
51 void Drag(int delta_x); | 52 void Drag(int delta_x); |
52 void EndDragging(bool cancelled); | 53 void EndDragging(bool cancelled); |
53 | 54 |
54 // Invoked when a panel's expansion state changes. | 55 // Invoked when a panel's expansion state changes. |
55 void OnPanelExpansionStateChanged(Panel::ExpansionState old_state, | 56 void OnPanelExpansionStateChanged(Panel* panel, |
56 Panel::ExpansionState new_state); | 57 Panel::ExpansionState old_state); |
57 | 58 |
58 // Invoked when the preferred window size of the given panel might need to | 59 // Invoked when the preferred window size of the given panel might need to |
59 // get changed. | 60 // get changed. |
60 void OnPreferredWindowSizeChanged( | 61 void OnPreferredWindowSizeChanged( |
61 Panel* panel, const gfx::Size& preferred_window_size); | 62 Panel* panel, const gfx::Size& preferred_window_size); |
62 | 63 |
63 // Returns true if we should bring up the titlebars, given the current mouse | 64 // Returns true if we should bring up the titlebars, given the current mouse |
64 // point. | 65 // point. |
65 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 66 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
66 | 67 |
67 // Brings up or down the titlebars for all minimized panels. | 68 // Brings up or down the titlebars for all minimized panels. |
68 void BringUpOrDownTitlebars(bool bring_up); | 69 void BringUpOrDownTitlebars(bool bring_up); |
69 | 70 |
70 // Returns the bottom position for the panel per its expansion state. If auto- | |
71 // hide bottom bar is present, we want to move the minimized panel to the | |
72 // bottom of the screen, not the bottom of the work area. | |
73 int GetBottomPositionForExpansionState( | |
74 Panel::ExpansionState expansion_state) const; | |
75 | |
76 // Returns the next browser window which could be either panel window or | 71 // Returns the next browser window which could be either panel window or |
77 // tabbed window, to switch to if the given panel is going to be deactivated. | 72 // tabbed window, to switch to if the given panel is going to be deactivated. |
78 // Returns NULL if such window cannot be found. | 73 // Returns NULL if such window cannot be found. |
79 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; | 74 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; |
80 | 75 |
81 int num_panels() const; | 76 int num_panels() const; |
82 bool is_dragging_panel() const; | 77 bool is_dragging_panel() const; |
83 int StartingRightPosition() const; | 78 int StartingRightPosition() const; |
84 const Panels& panels() const; | 79 const Panels& panels() const; |
85 | 80 |
86 // Moves a panel to the overflow strip. The panel does not currently | |
87 // belong in any other strip. | |
88 // |is_new| is true if the panel was just created. | |
89 void MoveToOverflowStrip(Panel* panel, bool is_new); | |
90 | |
91 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { | 81 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { |
92 return auto_hiding_desktop_bar_; | 82 return auto_hiding_desktop_bar_; |
93 } | 83 } |
94 | 84 |
95 PanelMouseWatcher* mouse_watcher() const { | 85 PanelMouseWatcher* mouse_watcher() const { |
96 return panel_mouse_watcher_.get(); | 86 return panel_mouse_watcher_.get(); |
97 } | 87 } |
98 | 88 |
99 PanelStrip* panel_strip() const { | 89 PanelStrip* panel_strip() const { |
100 return panel_strip_.get(); | 90 return panel_strip_.get(); |
101 } | 91 } |
102 | 92 |
| 93 PanelOverflowStrip* panel_overflow_strip() const { |
| 94 return panel_overflow_strip_.get(); |
| 95 } |
| 96 |
103 #ifdef UNIT_TEST | 97 #ifdef UNIT_TEST |
104 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } | 98 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } |
105 | 99 |
106 const gfx::Rect& work_area() const { | 100 const gfx::Rect& work_area() const { |
107 return work_area_; | 101 return work_area_; |
108 } | 102 } |
109 | 103 |
110 void set_auto_hiding_desktop_bar( | 104 void set_auto_hiding_desktop_bar( |
111 AutoHidingDesktopBar* auto_hiding_desktop_bar) { | 105 AutoHidingDesktopBar* auto_hiding_desktop_bar) { |
112 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; | 106 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // code. | 143 // code. |
150 void SetWorkArea(const gfx::Rect& work_area); | 144 void SetWorkArea(const gfx::Rect& work_area); |
151 | 145 |
152 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. | 146 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. |
153 void AdjustWorkAreaForAutoHidingDesktopBars(); | 147 void AdjustWorkAreaForAutoHidingDesktopBars(); |
154 | 148 |
155 // Positions the various groupings of panels. | 149 // Positions the various groupings of panels. |
156 void Layout(); | 150 void Layout(); |
157 | 151 |
158 scoped_ptr<PanelStrip> panel_strip_; | 152 scoped_ptr<PanelStrip> panel_strip_; |
| 153 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_; |
159 | 154 |
160 // Use a mouse watcher to know when to bring up titlebars to "peek" at | 155 // Use a mouse watcher to know when to bring up titlebars to "peek" at |
161 // minimized panels. Mouse movement is only tracked when there is a minimized | 156 // minimized panels. Mouse movement is only tracked when there is a minimized |
162 // panel. | 157 // panel. |
163 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; | 158 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; |
164 | 159 |
165 // The maximum work area avaialble. This area does not include the area taken | 160 // The maximum work area avaialble. This area does not include the area taken |
166 // by the always-visible (non-auto-hiding) desktop bars. | 161 // by the always-visible (non-auto-hiding) desktop bars. |
167 gfx::Rect work_area_; | 162 gfx::Rect work_area_; |
168 | 163 |
169 // The useable work area for computing the panel bounds. This area excludes | 164 // The useable work area for computing the panel bounds. This area excludes |
170 // the potential area that could be taken by the auto-hiding desktop | 165 // the potential area that could be taken by the auto-hiding desktop |
171 // bars (we only consider those bars that are aligned to bottom, left, and | 166 // bars (we only consider those bars that are aligned to bottom, left, and |
172 // right of the screen edges) when they become fully visible. | 167 // right of the screen edges) when they become fully visible. |
173 gfx::Rect adjusted_work_area_; | 168 gfx::Rect adjusted_work_area_; |
174 | 169 |
175 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_; | 170 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_; |
176 | 171 |
177 // Whether or not bounds will be updated when the preferred content size is | 172 // Whether or not bounds will be updated when the preferred content size is |
178 // changed. The testing code could set this flag to false so that other tests | 173 // changed. The testing code could set this flag to false so that other tests |
179 // will not be affected. | 174 // will not be affected. |
180 bool auto_sizing_enabled_; | 175 bool auto_sizing_enabled_; |
181 | 176 |
182 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 177 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
183 }; | 178 }; |
184 | 179 |
185 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 180 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
OLD | NEW |