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

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

Issue 8774013: Add panel overflow logic to panel strip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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_STRIP_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_
6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ 6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_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 12 matching lines...) Expand all
23 // All panels in the strip are contained within the bounds of the strip. 23 // All panels in the strip are contained within the bounds of the strip.
24 class PanelStrip : public PanelMouseWatcherObserver { 24 class PanelStrip : public PanelMouseWatcherObserver {
25 public: 25 public:
26 typedef std::vector<Panel*> Panels; 26 typedef std::vector<Panel*> Panels;
27 27
28 explicit PanelStrip(PanelManager* panel_manager); 28 explicit PanelStrip(PanelManager* panel_manager);
29 virtual ~PanelStrip(); 29 virtual ~PanelStrip();
30 30
31 // Sets the bounds of the panel strip. 31 // Sets the bounds of the panel strip.
32 // |bounds| is in screen coordinates. 32 // |bounds| is in screen coordinates.
33 void SetBounds(const gfx::Rect bounds); 33 void SetDisplayArea(const gfx::Rect area);
jianli 2011/12/01 21:36:28 nit: add "&" after Rect.
jennb 2011/12/01 23:10:17 Done.
34 34
35 // Adds a panel to the strip. The panel may be a newly created panel or one 35 // Adds a panel to the strip. The panel may be a newly created panel or one
36 // that is transitioning from another grouping of panels. 36 // that is transitioning from another grouping of panels.
37 void AddPanel(Panel* panel); 37 void AddPanel(Panel* panel);
38 38
39 // Returns |false| if the panel is not in the strip. 39 // Returns |false| if the panel is not in the strip.
40 bool Remove(Panel* panel); 40 bool Remove(Panel* panel);
41 void RemoveAll(); 41 void RemoveAll();
42 42
43 // Drags the given panel. 43 // Drags the given panel.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void AddNewPanel(Panel* panel); 105 void AddNewPanel(Panel* panel);
106 void AddExistingPanel(Panel* panel); 106 void AddExistingPanel(Panel* panel);
107 107
108 // Keep track of the minimized panels to control mouse watching. 108 // Keep track of the minimized panels to control mouse watching.
109 void IncrementMinimizedPanels(); 109 void IncrementMinimizedPanels();
110 void DecrementMinimizedPanels(); 110 void DecrementMinimizedPanels();
111 111
112 // Handles all the panels that're delayed to be removed. 112 // Handles all the panels that're delayed to be removed.
113 void DelayedRemove(); 113 void DelayedRemove();
114 114
115 // Does the remove. Called from Remove and DelayedRemove. 115 // Does the actual remove. Caller is responsible for rearranging
116 void DoRemove(Panel* panel); 116 // the panel strip if necessary.
117 // Returns |false| if panel is not in the strip.
118 bool DoRemove(Panel* panel);
117 119
118 // Rearranges the positions of the panels starting from the given iterator. 120 // Rearranges the positions of the panels in the strip.
119 // This is called when the display space has been changed, i.e. working 121 // This is called when the display space has been changed, i.e. working
120 // area being changed or a panel being closed. 122 // area being changed or a panel being closed.
121 void Rearrange(Panels::iterator iter_to_start, int rightmost_position); 123 void Rearrange();
122 124
123 // Help functions to drag the given panel. 125 // Help functions to drag the given panel.
124 void DragLeft(); 126 void DragLeft();
125 void DragRight(); 127 void DragRight();
126 128
127 // Does the real job of bringing up or down the titlebars. 129 // Does the real job of bringing up or down the titlebars.
128 void DoBringUpOrDownTitlebars(bool bring_up); 130 void DoBringUpOrDownTitlebars(bool bring_up);
129 // The callback for a delyed task, checks if it still need to perform 131 // The callback for a delyed task, checks if it still need to perform
130 // the delayed action. 132 // the delayed action.
131 void DelayedBringUpOrDownTitlebarsCheck(); 133 void DelayedBringUpOrDownTitlebarsCheck();
132 134
133 int GetRightMostAvailablePosition() const; 135 int GetRightMostAvailablePosition() const;
134 136
137 void MovePanelToOverflow(Panel* panel, bool is_new);
jianli 2011/12/01 21:36:28 Could you please add comment for this, like explai
jennb 2011/12/01 23:10:17 Done.
138
139 // Adds zero or more panels from overflow as will fit in the panel strip.
140 void AddPanelsFromOverflow();
jianli 2011/12/01 21:36:28 How about MovePanelsFromOverflowIfNeeded?
jennb 2011/12/01 23:10:17 Done.
141
135 PanelManager* panel_manager_; // Weak, owns us. 142 PanelManager* panel_manager_; // Weak, owns us.
136 143
137 // All panels in the panel strip must fit within this area. 144 // All panels in the panel strip must fit within this area.
138 gfx::Rect strip_bounds_; 145 gfx::Rect display_area_;
139 146
140 Panels panels_; 147 Panels panels_;
141 148
142 // Stores the panels that are pending to remove. We want to delay the removal 149 // Stores the panels that are pending to remove. We want to delay the removal
143 // when we're in the process of the dragging. 150 // when we're in the process of the dragging.
144 Panels panels_pending_to_remove_; 151 Panels panels_pending_to_remove_;
145 152
146 int minimized_panel_count_; 153 int minimized_panel_count_;
147 bool are_titlebars_up_; 154 bool are_titlebars_up_;
148 155
149 // Panel to drag. 156 // Panel to drag.
150 size_t dragging_panel_index_; 157 size_t dragging_panel_index_;
151 158
152 // Original x coordinate of the panel to drag. This is used to get back to 159 // Original x coordinate of the panel to drag. This is used to get back to
153 // the original position when we cancel the dragging. 160 // the original position when we cancel the dragging.
154 int dragging_panel_original_x_; 161 int dragging_panel_original_x_;
155 162
156 // Bounds of the panel to drag. It is first set to the original bounds when 163 // Bounds of the panel to drag. It is first set to the original bounds when
157 // the dragging happens. Then it is updated to the position that will be set 164 // the dragging happens. Then it is updated to the position that will be set
158 // to when the dragging ends. 165 // to when the dragging ends.
159 gfx::Rect dragging_panel_bounds_; 166 gfx::Rect dragging_panel_bounds_;
160 167
161 // Delayed transitions support. Sometimes transitions between minimized and 168 // Delayed transitions support. Sometimes transitions between minimized and
162 // title-only states are delayed, for better usability with Taskbars/Docks. 169 // title-only states are delayed, for better usability with Taskbars/Docks.
163 TitlebarAction delayed_titlebar_action_; 170 TitlebarAction delayed_titlebar_action_;
164 bool remove_delays_for_testing_; 171 bool remove_delays_for_testing_;
165 // Owned by MessageLoop after posting. 172 // Owned by MessageLoop after posting.
166 base::WeakPtrFactory<PanelStrip> titlebar_action_factory_; 173 base::WeakPtrFactory<PanelStrip> titlebar_action_factory_;
167 174
175 // Factory used for moving new panels to overflow after a delay.
176 base::WeakPtrFactory<PanelStrip> overflow_action_factory_;
177
168 static const int kPanelsHorizontalSpacing = 4; 178 static const int kPanelsHorizontalSpacing = 4;
169 179
170 // Absolute minimum width and height for panels, including non-client area. 180 // Absolute minimum width and height for panels, including non-client area.
171 // Should only be big enough to accomodate a close button on the reasonably 181 // Should only be big enough to accomodate a close button on the reasonably
172 // recognisable titlebar. 182 // recognisable titlebar.
173 static const int kPanelMinWidth; 183 static const int kPanelMinWidth;
174 static const int kPanelMinHeight; 184 static const int kPanelMinHeight;
175 185
176 DISALLOW_COPY_AND_ASSIGN(PanelStrip); 186 DISALLOW_COPY_AND_ASSIGN(PanelStrip);
177 }; 187 };
178 188
179 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ 189 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698