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

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

Issue 8827011: Panel strip refactor cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 years 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) 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
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 108
123 void remove_delays_for_testing() { 109 void SetMouseWatcherForTesting(PanelMouseWatcher* watcher) {
124 panel_strip_->remove_delays_for_testing(); 110 SetMouseWatcher(watcher);
125 }
126
127 int minimized_panel_count() {
128 return panel_strip_->minimized_panel_count();
129 } 111 }
130 #endif 112 #endif
131 113
132 private: 114 private:
133 friend struct base::DefaultLazyInstanceTraits<PanelManager>; 115 friend struct base::DefaultLazyInstanceTraits<PanelManager>;
134 116
135 PanelManager(); 117 PanelManager();
136 virtual ~PanelManager(); 118 virtual ~PanelManager();
137 119
138 // Overridden from AutoHidingDesktopBar::Observer: 120 // Overridden from AutoHidingDesktopBar::Observer:
139 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE; 121 virtual void OnAutoHidingDesktopBarThicknessChanged() OVERRIDE;
140 virtual void OnAutoHidingDesktopBarVisibilityChanged( 122 virtual void OnAutoHidingDesktopBarVisibilityChanged(
141 AutoHidingDesktopBar::Alignment alignment, 123 AutoHidingDesktopBar::Alignment alignment,
142 AutoHidingDesktopBar::Visibility visibility) OVERRIDE; 124 AutoHidingDesktopBar::Visibility visibility) OVERRIDE;
143 125
144 // Applies the new work area. This is called by OnDisplayChanged and the test 126 // Applies the new work area. This is called by OnDisplayChanged and the test
145 // code. 127 // code.
146 void SetWorkArea(const gfx::Rect& work_area); 128 void SetWorkArea(const gfx::Rect& work_area);
147 129
148 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. 130 // Adjusts the work area to exclude the influence of auto-hiding desktop bars.
149 void AdjustWorkAreaForAutoHidingDesktopBars(); 131 void AdjustWorkAreaForAutoHidingDesktopBars();
150 132
151 // Positions the various groupings of panels. 133 // Positions the various groupings of panels.
152 void Layout(); 134 void Layout();
153 135
154 // Tests if the current active app is in full screen mode. 136 // Tests if the current active app is in full screen mode.
155 void CheckFullScreenMode(); 137 void CheckFullScreenMode();
156 138
139 // Tests may want to use a mock panel mouse watcher.
140 void SetMouseWatcher(PanelMouseWatcher* watcher);
141
157 scoped_ptr<PanelStrip> panel_strip_; 142 scoped_ptr<PanelStrip> panel_strip_;
158 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_; 143 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_;
159 144
160 // Use a mouse watcher to know when to bring up titlebars to "peek" at 145 // 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 146 // minimized panels. Mouse movement is only tracked when there is a minimized
162 // panel. 147 // panel.
163 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; 148 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_;
164 149
165 // The maximum work area avaialble. This area does not include the area taken 150 // The maximum work area avaialble. This area does not include the area taken
166 // by the always-visible (non-auto-hiding) desktop bars. 151 // by the always-visible (non-auto-hiding) desktop bars.
(...skipping 15 matching lines...) Expand all
182 // Timer used to track if the current active app is in full screen mode. 167 // Timer used to track if the current active app is in full screen mode.
183 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; 168 base::RepeatingTimer<PanelManager> full_screen_mode_timer_;
184 169
185 // True if current active app is in full screen mode. 170 // True if current active app is in full screen mode.
186 bool is_full_screen_; 171 bool is_full_screen_;
187 172
188 DISALLOW_COPY_AND_ASSIGN(PanelManager); 173 DISALLOW_COPY_AND_ASSIGN(PanelManager);
189 }; 174 };
190 175
191 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 176 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browsertest.cc ('k') | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698