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

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, 5 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"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/panels/panel.h"
13 #include "chrome/browser/ui/window_sizer.h" 12 #include "chrome/browser/ui/window_sizer.h"
14 13
15 namespace { 14 namespace {
16 // Invalid panel index. 15 // Invalid panel index.
17 const size_t kInvalidPanelIndex = static_cast<size_t>(-1); 16 const size_t kInvalidPanelIndex = static_cast<size_t>(-1);
18 17
19 // Minimum width and height of a panel. 18 // Minimum width and height of a panel.
20 const int kPanelMinWidthPixels = 64; 19 const int kPanelMinWidthPixels = 64;
21 const int kPanelMinHeightPixels = 24; 20 const int kPanelMinHeightPixels = 24;
22 21
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } else { 262 } else {
264 active_panels_[dragging_panel_index_]->SetPanelBounds( 263 active_panels_[dragging_panel_index_]->SetPanelBounds(
265 dragging_panel_bounds_); 264 dragging_panel_bounds_);
266 } 265 }
267 266
268 dragging_panel_index_ = kInvalidPanelIndex; 267 dragging_panel_index_ = kInvalidPanelIndex;
269 268
270 DelayedRemove(); 269 DelayedRemove();
271 } 270 }
272 271
272 bool PanelManager::ShouldBringUpTitleBarForAllMinimizedPanels(
jennb 2011/06/29 23:17:54 Rather than ask every panel if it should bring up
jianli 2011/06/30 01:28:33 I've thought about providing the iteration API but
273 int mouse_x, int mouse_y) const {
274 for (ActivePanels::const_iterator iter = active_panels_.begin();
275 iter != active_panels_.end(); ++iter) {
276 if ((*iter)->ShouldBringUpTitleBar(mouse_x, mouse_y))
277 return true;
278 }
279 return false;
280 }
281
282 void PanelManager::BringUpOrDownTitleBarForAllMinimizedPanels(bool bring_up) {
283 for (ActivePanels::const_iterator iter = active_panels_.begin();
284 iter != active_panels_.end(); ++iter) {
285 if (bring_up) {
286 if ((*iter)->expansion_state() == Panel::MINIMIZED)
287 (*iter)->SetExpansionState(Panel::TITLE_ONLY);
288 } else {
289 if ((*iter)->expansion_state() == Panel::TITLE_ONLY)
290 (*iter)->SetExpansionState(Panel::MINIMIZED);
291 }
292 }
293 }
294
273 void PanelManager::Rearrange(ActivePanels::iterator iter_to_start) { 295 void PanelManager::Rearrange(ActivePanels::iterator iter_to_start) {
274 if (iter_to_start == active_panels_.end()) 296 if (iter_to_start == active_panels_.end())
275 return; 297 return;
276 298
277 for (ActivePanels::iterator iter = iter_to_start; 299 for (ActivePanels::iterator iter = iter_to_start;
278 iter != active_panels_.end(); ++iter) { 300 iter != active_panels_.end(); ++iter) {
279 gfx::Rect new_bounds((*iter)->GetBounds()); 301 gfx::Rect new_bounds((*iter)->GetBounds());
280 ComputeBoundsForNextPanel(&new_bounds, false); 302 ComputeBoundsForNextPanel(&new_bounds, false);
281 if (new_bounds != (*iter)->GetBounds()) 303 if (new_bounds != (*iter)->GetBounds())
282 (*iter)->SetPanelBounds(new_bounds); 304 (*iter)->SetPanelBounds(new_bounds);
(...skipping 28 matching lines...) Expand all
311 333
312 if (x < min_x_) 334 if (x < min_x_)
313 return false; 335 return false;
314 336
315 current_x_ -= width + kPanelsHorizontalSpacing; 337 current_x_ -= width + kPanelsHorizontalSpacing;
316 338
317 bounds->SetRect(x, y, width, height); 339 bounds->SetRect(x, y, width, height);
318 return true; 340 return true;
319 } 341 }
320 342
321 void PanelManager::MinimizeAll() {
322 for (ActivePanels::const_iterator iter = active_panels_.begin();
323 iter != active_panels_.end(); ++iter) {
324 (*iter)->Minimize();
325 }
326 }
327
328 void PanelManager::RestoreAll() {
329 for (ActivePanels::const_iterator iter = active_panels_.begin();
330 iter != active_panels_.end(); ++iter) {
331 (*iter)->Restore();
332 }
333 }
334
335 void PanelManager::RemoveAllActive() { 343 void PanelManager::RemoveAllActive() {
336 // This should not be called when we're in the process of dragging. 344 // This should not be called when we're in the process of dragging.
337 DCHECK(dragging_panel_index_ == kInvalidPanelIndex); 345 DCHECK(dragging_panel_index_ == kInvalidPanelIndex);
338 346
339 // Start from the bottom to avoid reshuffling. 347 // Start from the bottom to avoid reshuffling.
340 for (int i = static_cast<int>(active_panels_.size()) -1; i >= 0; --i) 348 for (int i = static_cast<int>(active_panels_.size()) -1; i >= 0; --i)
341 active_panels_[i]->Close(); 349 active_panels_[i]->Close();
342 350
343 ProcessPending(); 351 ProcessPending();
344 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698