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 "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 // TODO(jennb): Clean up by removing functions below that cause this | |
19 // to be required. | |
20 #ifdef UNIT_TEST | |
21 #include "chrome/browser/ui/panels/panel_strip.h" | |
22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | |
23 #endif | |
24 | |
25 class Browser; | 18 class Browser; |
26 class PanelMouseWatcher; | 19 class PanelMouseWatcher; |
27 class PanelOverflowStrip; | 20 class PanelOverflowStrip; |
28 class PanelStrip; | 21 class PanelStrip; |
29 | 22 |
30 // This class manages a set of panels. | 23 // This class manages a set of panels. |
31 class PanelManager : public AutoHidingDesktopBar::Observer { | 24 class PanelManager : public AutoHidingDesktopBar::Observer { |
32 public: | 25 public: |
33 typedef std::vector<Panel*> Panels; | 26 typedef std::vector<Panel*> Panels; |
34 | 27 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 61 |
69 // Brings up or down the titlebars for all minimized panels. | 62 // Brings up or down the titlebars for all minimized panels. |
70 void BringUpOrDownTitlebars(bool bring_up); | 63 void BringUpOrDownTitlebars(bool bring_up); |
71 | 64 |
72 // Returns the next browser window which could be either panel window or | 65 // Returns the next browser window which could be either panel window or |
73 // tabbed window, to switch to if the given panel is going to be deactivated. | 66 // tabbed window, to switch to if the given panel is going to be deactivated. |
74 // Returns NULL if such window cannot be found. | 67 // Returns NULL if such window cannot be found. |
75 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; | 68 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; |
76 | 69 |
77 int num_panels() const; | 70 int num_panels() const; |
78 bool is_dragging_panel() const; | |
79 int StartingRightPosition() const; | 71 int StartingRightPosition() const; |
80 const Panels& panels() const; | 72 const Panels& panels() const; |
81 | 73 |
82 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { | 74 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { |
83 return auto_hiding_desktop_bar_; | 75 return auto_hiding_desktop_bar_; |
84 } | 76 } |
85 | 77 |
86 PanelMouseWatcher* mouse_watcher() const { | 78 PanelMouseWatcher* mouse_watcher() const { |
87 return panel_mouse_watcher_.get(); | 79 return panel_mouse_watcher_.get(); |
88 } | 80 } |
89 | 81 |
90 PanelStrip* panel_strip() const { | 82 PanelStrip* panel_strip() const { |
91 return panel_strip_.get(); | 83 return panel_strip_.get(); |
92 } | 84 } |
93 | 85 |
94 bool is_full_screen() const { return is_full_screen_; } | 86 bool is_full_screen() const { return is_full_screen_; } |
95 PanelOverflowStrip* panel_overflow_strip() const { | 87 PanelOverflowStrip* panel_overflow_strip() const { |
96 return panel_overflow_strip_.get(); | 88 return panel_overflow_strip_.get(); |
97 } | 89 } |
98 | 90 |
99 #ifdef UNIT_TEST | 91 #ifdef UNIT_TEST |
100 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } | |
101 | |
102 const gfx::Rect& work_area() const { | |
103 return work_area_; | |
104 } | |
105 | |
106 void set_auto_hiding_desktop_bar( | 92 void set_auto_hiding_desktop_bar( |
107 AutoHidingDesktopBar* auto_hiding_desktop_bar) { | 93 AutoHidingDesktopBar* auto_hiding_desktop_bar) { |
108 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; | 94 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; |
109 } | 95 } |
110 | 96 |
111 void set_mouse_watcher(PanelMouseWatcher* watcher) { | |
112 panel_mouse_watcher_.reset(watcher); | |
113 } | |
114 | |
115 void enable_auto_sizing(bool enabled) { | 97 void enable_auto_sizing(bool enabled) { |
116 auto_sizing_enabled_ = enabled; | 98 auto_sizing_enabled_ = enabled; |
117 } | 99 } |
118 | 100 |
101 const gfx::Rect& work_area() const { | |
102 return work_area_; | |
103 } | |
104 | |
119 void SetWorkAreaForTesting(const gfx::Rect& work_area) { | 105 void SetWorkAreaForTesting(const gfx::Rect& work_area) { |
120 SetWorkArea(work_area); | 106 SetWorkArea(work_area); |
121 } | 107 } |
122 | |
123 void remove_delays_for_testing() { | |
124 panel_strip_->remove_delays_for_testing(); | |
125 } | |
126 | |
127 int minimized_panel_count() { | |
128 return panel_strip_->minimized_panel_count(); | |
129 } | |
130 #endif | 108 #endif |
131 | 109 |
132 private: | 110 private: |
133 friend struct base::DefaultLazyInstanceTraits<PanelManager>; | 111 friend struct base::DefaultLazyInstanceTraits<PanelManager>; |
112 friend class PanelBrowserTest; // for SetMouseWatcher() | |
jianli
2011/12/08 00:27:54
As discussed, we can do sth. similar to SetWorkAre
| |
113 FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, DrawAttentionWhileMinimized); | |
114 FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, MinimizeRestore); | |
115 FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, MinimizeRestoreTwoPanels); | |
116 FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, MinimizeRestoreThreePanels); | |
117 FRIEND_TEST_ALL_PREFIXES(PanelBrowserTest, RestoredBounds); | |
134 | 118 |
135 PanelManager(); | 119 PanelManager(); |
136 virtual ~PanelManager(); | 120 virtual ~PanelManager(); |
137 | 121 |
138 // Overridden from AutoHidingDesktopBar::Observer: | 122 // Overridden from AutoHidingDesktopBar::Observer: |
139 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE; | 123 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE; |
140 virtual void OnAutoHidingDesktopBarVisibilityChanged( | 124 virtual void OnAutoHidingDesktopBarVisibilityChanged( |
141 AutoHidingDesktopBar::Alignment alignment, | 125 AutoHidingDesktopBar::Alignment alignment, |
142 AutoHidingDesktopBar::Visibility visibility) OVERRIDE; | 126 AutoHidingDesktopBar::Visibility visibility) OVERRIDE; |
143 | 127 |
144 // Applies the new work area. This is called by OnDisplayChanged and the test | 128 // Applies the new work area. This is called by OnDisplayChanged and the test |
145 // code. | 129 // code. |
146 void SetWorkArea(const gfx::Rect& work_area); | 130 void SetWorkArea(const gfx::Rect& work_area); |
147 | 131 |
148 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. | 132 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. |
149 void AdjustWorkAreaForAutoHidingDesktopBars(); | 133 void AdjustWorkAreaForAutoHidingDesktopBars(); |
150 | 134 |
151 // Positions the various groupings of panels. | 135 // Positions the various groupings of panels. |
152 void Layout(); | 136 void Layout(); |
153 | 137 |
154 // Tests if the current active app is in full screen mode. | 138 // Tests if the current active app is in full screen mode. |
155 void CheckFullScreenMode(); | 139 void CheckFullScreenMode(); |
156 | 140 |
141 // Tests may want to use a mock panel mouse watcher. | |
142 void SetMouseWatcher(PanelMouseWatcher* watcher); | |
143 | |
157 scoped_ptr<PanelStrip> panel_strip_; | 144 scoped_ptr<PanelStrip> panel_strip_; |
158 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_; | 145 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_; |
159 | 146 |
160 // Use a mouse watcher to know when to bring up titlebars to "peek" at | 147 // 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 | 148 // minimized panels. Mouse movement is only tracked when there is a minimized |
162 // panel. | 149 // panel. |
163 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; | 150 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; |
164 | 151 |
165 // The maximum work area avaialble. This area does not include the area taken | 152 // The maximum work area avaialble. This area does not include the area taken |
166 // by the always-visible (non-auto-hiding) desktop bars. | 153 // by the always-visible (non-auto-hiding) desktop bars. |
(...skipping 15 matching lines...) Expand all Loading... | |
182 // Timer used to track if the current active app is in full screen mode. | 169 // Timer used to track if the current active app is in full screen mode. |
183 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; | 170 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; |
184 | 171 |
185 // True if current active app is in full screen mode. | 172 // True if current active app is in full screen mode. |
186 bool is_full_screen_; | 173 bool is_full_screen_; |
187 | 174 |
188 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 175 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
189 }; | 176 }; |
190 | 177 |
191 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 178 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
OLD | NEW |