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

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

Issue 7242017: Support minimizing the panel into 3-pixel line on Windows. Also support bringing up/down the titl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 6 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) 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 #include "chrome/browser/ui/panels/panel_manager.h" 5 #include "chrome/browser/ui/panels/panel_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 21 matching lines...) Expand all
32 // Horizontal spacing between two panels. 32 // Horizontal spacing between two panels.
33 const int kPanelsHorizontalSpacing = 4; 33 const int kPanelsHorizontalSpacing = 4;
34 34
35 // Single instance of PanelManager. 35 // Single instance of PanelManager.
36 scoped_ptr<PanelManager> panel_instance; 36 scoped_ptr<PanelManager> panel_instance;
37 } // namespace 37 } // namespace
38 38
39 // static 39 // static
40 PanelManager* PanelManager::GetInstance() { 40 PanelManager* PanelManager::GetInstance() {
41 if (!panel_instance.get()) { 41 if (!panel_instance.get()) {
42 panel_instance.reset(new PanelManager()); 42 panel_instance.reset(PanelManager::Create());
43 } 43 }
44 return panel_instance.get(); 44 return panel_instance.get();
45 } 45 }
46 46
47 // static
48 #if !defined(OS_WIN)
49 PanelManager* PanelManager::Create() {
jennb 2011/06/27 23:18:02 Why only when not Windows?
jianli 2011/06/29 01:28:12 Not needed. Reverted.
50 return new PanelManager();
51 }
52 #endif
53
47 PanelManager::PanelManager() 54 PanelManager::PanelManager()
48 : max_width_(0), 55 : max_width_(0),
49 max_height_(0), 56 max_height_(0),
50 min_x_(0), 57 min_x_(0),
51 current_x_(0), 58 current_x_(0),
52 bottom_edge_y_(0), 59 bottom_edge_y_(0),
53 dragging_panel_index_(kInvalidPanelIndex), 60 dragging_panel_index_(kInvalidPanelIndex),
54 dragging_panel_original_x_(0) { 61 dragging_panel_original_x_(0) {
55 OnDisplayChanged(); 62 OnDisplayChanged();
56 } 63 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 318
312 if (x < min_x_) 319 if (x < min_x_)
313 return false; 320 return false;
314 321
315 current_x_ -= width + kPanelsHorizontalSpacing; 322 current_x_ -= width + kPanelsHorizontalSpacing;
316 323
317 bounds->SetRect(x, y, width, height); 324 bounds->SetRect(x, y, width, height);
318 return true; 325 return true;
319 } 326 }
320 327
328 void PanelManager::Minimize(Panel* panel) {
329 panel->Minimize();
330 }
331
332 void PanelManager::Restore(Panel* panel, bool titlebar_only) {
333 panel->Restore(titlebar_only);
334 }
335
321 void PanelManager::MinimizeAll() { 336 void PanelManager::MinimizeAll() {
322 for (ActivePanels::const_iterator iter = active_panels_.begin(); 337 for (ActivePanels::const_iterator iter = active_panels_.begin();
323 iter != active_panels_.end(); ++iter) { 338 iter != active_panels_.end(); ++iter) {
324 (*iter)->Minimize(); 339 Minimize(*iter);
325 } 340 }
326 } 341 }
327 342
328 void PanelManager::RestoreAll() { 343 void PanelManager::RestoreAll() {
329 for (ActivePanels::const_iterator iter = active_panels_.begin(); 344 for (ActivePanels::const_iterator iter = active_panels_.begin();
330 iter != active_panels_.end(); ++iter) { 345 iter != active_panels_.end(); ++iter) {
331 (*iter)->Restore(); 346 Restore(*iter, false);
332 } 347 }
333 } 348 }
334 349
335 void PanelManager::RemoveAllActive() { 350 void PanelManager::RemoveAllActive() {
336 // This should not be called when we're in the process of dragging. 351 // This should not be called when we're in the process of dragging.
337 DCHECK(dragging_panel_index_ == kInvalidPanelIndex); 352 DCHECK(dragging_panel_index_ == kInvalidPanelIndex);
338 353
339 // Start from the bottom to avoid reshuffling. 354 // Start from the bottom to avoid reshuffling.
340 for (int i = static_cast<int>(active_panels_.size()) -1; i >= 0; --i) 355 for (int i = static_cast<int>(active_panels_.size()) -1; i >= 0; --i)
341 active_panels_[i]->Close(); 356 active_panels_[i]->Close();
342 357
343 ProcessPending(); 358 ProcessPending();
344 } 359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698