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

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

Issue 8341098: Mac: Added a delay before panels go to minimized state from title-only state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disabled win test Created 9 years, 1 month 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/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/task.h" 13 #include "base/task.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 "chrome/browser/ui/panels/panel_mouse_watcher.h" 16 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 18
19 class Browser; 19 class Browser;
20 class Panel; 20 class Panel;
21 21
22 // This class manages a set of panels. 22 // This class manages a set of panels.
23 // Note that the ref count is needed by using PostTask in the implementation. 23 // Note that the ref count is needed by using PostTask in the implementation.
24 class PanelManager : public PanelMouseWatcher::Observer, 24 class PanelManager : public PanelMouseWatcher::Observer,
25 public AutoHidingDesktopBar::Observer, 25 public AutoHidingDesktopBar::Observer {
26 public base::RefCounted<PanelManager> {
27 public: 26 public:
28 typedef std::vector<Panel*> Panels; 27 typedef std::vector<Panel*> Panels;
29 28
30 // Returns a single instance. 29 // Returns a single instance.
31 static PanelManager* GetInstance(); 30 static PanelManager* GetInstance();
32 31
33 virtual ~PanelManager(); 32 virtual ~PanelManager();
34 33
35 // 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.
36 void OnDisplayChanged(); 35 void OnDisplayChanged();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 93 }
95 94
96 void enable_auto_sizing(bool enabled) { 95 void enable_auto_sizing(bool enabled) {
97 auto_sizing_enabled_ = enabled; 96 auto_sizing_enabled_ = enabled;
98 } 97 }
99 98
100 void SetWorkAreaForTesting(const gfx::Rect& work_area) { 99 void SetWorkAreaForTesting(const gfx::Rect& work_area) {
101 SetWorkArea(work_area); 100 SetWorkArea(work_area);
102 } 101 }
103 102
103 void remove_delays_for_testing() {
104 remove_delays_for_testing_ = true;
105 }
106
104 int minimized_panel_count() { 107 int minimized_panel_count() {
105 return minimized_panel_count_; 108 return minimized_panel_count_;
106 } 109 }
107 110
108 // Tests should disable mouse watching if mouse movements will be simulated. 111 // Tests should disable mouse watching if mouse movements will be simulated.
109 void disable_mouse_watching() { 112 void disable_mouse_watching() {
110 mouse_watching_disabled_ = true; 113 mouse_watching_disabled_ = true;
111 } 114 }
112 #endif 115 #endif
113 116
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 148
146 // Rearranges the positions of the panels starting from the given iterator. 149 // Rearranges the positions of the panels starting from the given iterator.
147 // This is called when the display space has been changed, i.e. working 150 // This is called when the display space has been changed, i.e. working
148 // area being changed or a panel being closed. 151 // area being changed or a panel being closed.
149 void Rearrange(Panels::iterator iter_to_start, int rightmost_position); 152 void Rearrange(Panels::iterator iter_to_start, int rightmost_position);
150 153
151 // Help functions to drag the given panel. 154 // Help functions to drag the given panel.
152 void DragLeft(); 155 void DragLeft();
153 void DragRight(); 156 void DragRight();
154 157
155 // Checks if the titlebars have been brought up or down. If not, do not wait
156 // for the notifications to trigger it any more, and start to bring them up or
157 // down immediately.
158 void DelayedBringUpOrDownTitlebarsCheck();
159
160 // Does the real job of bringing up or down the titlebars. 158 // Does the real job of bringing up or down the titlebars.
161 void DoBringUpOrDownTitlebars(bool bring_up); 159 void DoBringUpOrDownTitlebars(bool bring_up);
160 // The callback for a delyed task, checks if it still need to perform
161 // the delayed action.
162 void DelayedBringUpOrDownTitlebarsCheck();
162 163
163 int GetMaxPanelWidth() const; 164 int GetMaxPanelWidth() const;
164 int GetMaxPanelHeight() const; 165 int GetMaxPanelHeight() const;
165 int GetRightMostAvailablePosition() const; 166 int GetRightMostAvailablePosition() const;
166 167
167 Panels panels_; 168 Panels panels_;
168 169
169 // Stores the panels that are pending to remove. We want to delay the removal 170 // Stores the panels that are pending to remove. We want to delay the removal
170 // when we're in the process of the dragging. 171 // when we're in the process of the dragging.
171 Panels panels_pending_to_remove_; 172 Panels panels_pending_to_remove_;
(...skipping 22 matching lines...) Expand all
194 // the original position when we cancel the dragging. 195 // the original position when we cancel the dragging.
195 int dragging_panel_original_x_; 196 int dragging_panel_original_x_;
196 197
197 // Bounds of the panel to drag. It is first set to the original bounds when 198 // Bounds of the panel to drag. It is first set to the original bounds when
198 // the dragging happens. Then it is updated to the position that will be set 199 // the dragging happens. Then it is updated to the position that will be set
199 // to when the dragging ends. 200 // to when the dragging ends.
200 gfx::Rect dragging_panel_bounds_; 201 gfx::Rect dragging_panel_bounds_;
201 202
202 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_; 203 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_;
203 204
205 // Delayed transitions support. Sometimes transitions between minimized and
206 // title-only states are delayed, for better usability with Taskbars/Docks.
204 TitlebarAction delayed_titlebar_action_; 207 TitlebarAction delayed_titlebar_action_;
205 208 bool remove_delays_for_testing_;
206 ScopedRunnableMethodFactory<PanelManager> method_factory_; 209 // Owned by MessageLoop after posting.
210 CancelableTask* titlebar_action_task_;
207 211
208 // Whether or not bounds will be updated when the preferred content size is 212 // Whether or not bounds will be updated when the preferred content size is
209 // changed. The testing code could set this flag to false so that other tests 213 // changed. The testing code could set this flag to false so that other tests
210 // will not be affected. 214 // will not be affected.
211 bool auto_sizing_enabled_; 215 bool auto_sizing_enabled_;
212 216
213 bool mouse_watching_disabled_; // For tests to simulate mouse movements. 217 bool mouse_watching_disabled_; // For tests to simulate mouse movements.
214 218
215 static const int kPanelsHorizontalSpacing = 4; 219 static const int kPanelsHorizontalSpacing = 4;
216 220
217 // Minimum width and height of a panel. 221 // Minimum width and height of a panel.
218 // Note: The minimum size of a widget (see widget.cc) is fixed to 100x100. 222 // Note: The minimum size of a widget (see widget.cc) is fixed to 100x100.
219 // TODO(jianli): Need to fix this to support smaller panel. 223 // TODO(jianli): Need to fix this to support smaller panel.
220 static const int kPanelMinWidth = 100; 224 static const int kPanelMinWidth = 100;
221 static const int kPanelMinHeight = 100; 225 static const int kPanelMinHeight = 100;
222 226
223 DISALLOW_COPY_AND_ASSIGN(PanelManager); 227 DISALLOW_COPY_AND_ASSIGN(PanelManager);
224 }; 228 };
225 229
230 // Required for CancellableTask to be used with non-refcounted objects.
231 // Defines empty AddRef/Release.
232 DISABLE_RUNNABLE_METHOD_REFCOUNT(PanelManager);
233
226 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 234 #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