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

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

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
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int num_panels() const { return panels_.size(); } 48 int num_panels() const { return panels_.size(); }
49 bool is_dragging_panel() const; 49 bool is_dragging_panel() const;
50 50
51 private: 51 private:
52 friend class PanelBrowserTest; 52 friend class PanelBrowserTest;
53 53
54 typedef std::vector<Panel*> Panels; 54 typedef std::vector<Panel*> Panels;
55 55
56 PanelManager(); 56 PanelManager();
57 57
58 #if UNIT_TEST
59 const Panels& panels() const { return panels_; }
60 static int horizontal_spacing() { return kPanelsHorizontalSpacing; }
61 #endif
62
58 // Applies the new work area. This is called by OnDisplayChanged and the test 63 // Applies the new work area. This is called by OnDisplayChanged and the test
59 // code. 64 // code.
60 void SetWorkArea(const gfx::Rect& work_area); 65 void SetWorkArea(const gfx::Rect& work_area);
61 66
62 // Handles all the panels that're delayed to be removed. 67 // Handles all the panels that're delayed to be removed.
63 void DelayedRemove(); 68 void DelayedRemove();
64 69
65 // Does the remove. Called from Remove and DelayedRemove. 70 // Does the remove. Called from Remove and DelayedRemove.
66 void DoRemove(Panel* panel); 71 void DoRemove(Panel* panel);
67 72
68 // Rearranges the positions of the panels starting from the given iterator. 73 // Rearranges the positions of the panels starting from the given iterator.
69 // This is called when the display space has been changed, i.e. working 74 // This is called when the display space has been changed, i.e. working
70 // area being changed or a panel being closed. 75 // area being changed or a panel being closed.
71 void Rearrange(Panels::iterator iter_to_start); 76 void Rearrange(Panels::iterator iter_to_start);
72 77
73 // Computes the bounds for next panel. 78 // Computes the bounds for next panel.
74 // |allow_size_change| is used to indicate if the panel size can be changed to 79 // |allow_size_change| is used to indicate if the panel size can be changed to
75 // fall within the size constraint, e.g., when the panel is created. 80 // fall within the size constraint, e.g., when the panel is created.
76 // Returns true if computed bounds are within the displayable area. 81 // Returns true if computed bounds are within the displayable area.
77 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change); 82 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change);
78 83
79 // Finds one panel to close so that we may have space for the new panel 84 // Finds one panel to close so that we may have space for the new panel
80 // created by |extension|. 85 // created by |extension|.
81 void FindAndClosePanelOnOverflow(const Extension* extension); 86 void FindAndClosePanelOnOverflow(const Extension* extension);
82 87
83 // Help functions to drag the given panel. 88 // Help functions to drag the given panel.
84 void DragLeft(); 89 void DragLeft();
85 void DragRight(); 90 void DragRight();
86 91
92 // Horizontal spacing between panels. Used for unit testing.
93
87 Panels panels_; 94 Panels panels_;
88 95
89 // Stores the panels that are pending to remove. We want to delay the removal 96 // Stores the panels that are pending to remove. We want to delay the removal
90 // when we're in the process of the dragging. 97 // when we're in the process of the dragging.
91 Panels panels_pending_to_remove_; 98 Panels panels_pending_to_remove_;
92 99
93 // Current work area used in computing the panel bounds. 100 // Current work area used in computing the panel bounds.
94 gfx::Rect work_area_; 101 gfx::Rect work_area_;
95 102
96 // Used in computing the bounds of the next panel. 103 // Used in computing the bounds of the next panel.
97 int max_width_; 104 int max_width_;
98 int max_height_; 105 int max_height_;
99 int min_x_; 106 int min_x_;
100 int current_x_; 107 int current_x_;
101 int bottom_edge_y_; 108 int bottom_edge_y_;
102 109
103 // Panel to drag. 110 // Panel to drag.
104 size_t dragging_panel_index_; 111 size_t dragging_panel_index_;
105 112
106 // Original x coordinate of the panel to drag. This is used to get back to 113 // Original x coordinate of the panel to drag. This is used to get back to
107 // the original position when we cancel the dragging. 114 // the original position when we cancel the dragging.
108 int dragging_panel_original_x_; 115 int dragging_panel_original_x_;
109 116
110 // Bounds of the panel to drag. It is first set to the original bounds when 117 // Bounds of the panel to drag. It is first set to the original bounds when
111 // the dragging happens. Then it is updated to the position that will be set 118 // the dragging happens. Then it is updated to the position that will be set
112 // to when the dragging ends. 119 // to when the dragging ends.
113 gfx::Rect dragging_panel_bounds_; 120 gfx::Rect dragging_panel_bounds_;
114 121
122 static const int kPanelsHorizontalSpacing = 4;
123
115 DISALLOW_COPY_AND_ASSIGN(PanelManager); 124 DISALLOW_COPY_AND_ASSIGN(PanelManager);
116 }; 125 };
117 126
118 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 127 #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