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

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

Issue 7706027: Addition testing for panels drag and drop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For testing on windows Created 9 years, 4 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
« no previous file with comments | « chrome/browser/ui/panels/panel_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 21
22 // Default width and height of a panel. 22 // Default width and height of a panel.
23 const int kPanelDefaultWidthPixels = 240; 23 const int kPanelDefaultWidthPixels = 240;
24 const int kPanelDefaultHeightPixels = 290; 24 const int kPanelDefaultHeightPixels = 290;
25 25
26 // Maxmium width and height of a panel based on the factor of the working 26 // Maxmium width and height of a panel based on the factor of the working
27 // area. 27 // area.
28 const double kPanelMaxWidthFactor = 1.0; 28 const double kPanelMaxWidthFactor = 1.0;
29 const double kPanelMaxHeightFactor = 0.5; 29 const double kPanelMaxHeightFactor = 0.5;
30 30
31 // Horizontal spacing between two panels.
32 const int kPanelsHorizontalSpacing = 4;
33
34 // Single instance of PanelManager. 31 // Single instance of PanelManager.
35 scoped_ptr<PanelManager> panel_instance; 32 scoped_ptr<PanelManager> panel_instance;
36 } // namespace 33 } // namespace
37 34
38 // static 35 // static
39 PanelManager* PanelManager::GetInstance() { 36 PanelManager* PanelManager::GetInstance() {
40 if (!panel_instance.get()) { 37 if (!panel_instance.get()) {
41 panel_instance.reset(new PanelManager()); 38 panel_instance.reset(new PanelManager());
42 } 39 }
43 return panel_instance.get(); 40 return panel_instance.get();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 current_x_ -= width + kPanelsHorizontalSpacing; 341 current_x_ -= width + kPanelsHorizontalSpacing;
345 342
346 bounds->SetRect(x, y, width, height); 343 bounds->SetRect(x, y, width, height);
347 return true; 344 return true;
348 } 345 }
349 346
350 void PanelManager::RemoveAll() { 347 void PanelManager::RemoveAll() {
351 // This should not be called when we're in the process of dragging. 348 // This should not be called when we're in the process of dragging.
352 DCHECK(dragging_panel_index_ == kInvalidPanelIndex); 349 DCHECK(dragging_panel_index_ == kInvalidPanelIndex);
353 350
351 // Make a copy of the iterator as closing panels can modify the vector.
352 Panels panels_copy = panels_;
353
354 // Start from the bottom to avoid reshuffling. 354 // Start from the bottom to avoid reshuffling.
355 for (Panels::reverse_iterator iter = panels_.rbegin(); 355 for (Panels::reverse_iterator iter = panels_copy.rbegin();
356 iter != panels_.rend(); ++iter) 356 iter != panels_copy.rend(); ++iter)
357 (*iter)->Close(); 357 (*iter)->Close();
358 } 358 }
359 359
360 bool PanelManager::is_dragging_panel() const { 360 bool PanelManager::is_dragging_panel() const {
361 return dragging_panel_index_ != kInvalidPanelIndex; 361 return dragging_panel_index_ != kInvalidPanelIndex;
362 } 362 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698