OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/docked_panel_strip.h" | 5 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 } | 442 } |
443 | 443 |
444 void DockedPanelStrip::DecrementMinimizedPanels() { | 444 void DockedPanelStrip::DecrementMinimizedPanels() { |
445 minimized_panel_count_--; | 445 minimized_panel_count_--; |
446 DCHECK_GE(minimized_panel_count_, 0); | 446 DCHECK_GE(minimized_panel_count_, 0); |
447 if (minimized_panel_count_ == 0) | 447 if (minimized_panel_count_ == 0) |
448 panel_manager_->mouse_watcher()->RemoveObserver(this); | 448 panel_manager_->mouse_watcher()->RemoveObserver(this); |
449 } | 449 } |
450 | 450 |
451 void DockedPanelStrip::ResizePanelWindow( | 451 void DockedPanelStrip::ResizePanelWindow( |
452 Panel* panel, const gfx::Size& preferred_window_size) { | 452 Panel* panel, |
| 453 const gfx::Size& preferred_window_size, |
| 454 AutoResizeState auto_resize_state) { |
| 455 DCHECK(auto_resize_state == AUTORESIZE_ENABLED || |
| 456 auto_resize_state == AUTORESIZE_DISABLED); |
453 // The panel width: | 457 // The panel width: |
454 // * cannot grow or shrink to go beyond [min_width, max_width] | 458 // * cannot grow or shrink to go beyond [min_width, max_width] |
455 int new_width = preferred_window_size.width(); | 459 int new_width = preferred_window_size.width(); |
456 if (new_width > panel->max_size().width()) | 460 if (new_width > panel->max_size().width()) |
457 new_width = panel->max_size().width(); | 461 new_width = panel->max_size().width(); |
458 if (new_width < panel->min_size().width()) | 462 if (new_width < panel->min_size().width()) |
459 new_width = panel->min_size().width(); | 463 new_width = panel->min_size().width(); |
460 | 464 |
461 // The panel height: | 465 // The panel height: |
462 // * cannot grow or shrink to go beyond [min_height, max_height] | 466 // * cannot grow or shrink to go beyond [min_height, max_height] |
463 int new_height = preferred_window_size.height(); | 467 int new_height = preferred_window_size.height(); |
464 if (new_height > panel->max_size().height()) | 468 if (new_height > panel->max_size().height()) |
465 new_height = panel->max_size().height(); | 469 new_height = panel->max_size().height(); |
466 if (new_height < panel->min_size().height()) | 470 if (new_height < panel->min_size().height()) |
467 new_height = panel->min_size().height(); | 471 new_height = panel->min_size().height(); |
468 | 472 |
469 // Update restored size. | 473 // Update restored size. |
470 gfx::Size new_size(new_width, new_height); | 474 gfx::Size new_size(new_width, new_height); |
471 if (new_size != panel->restored_size()) | 475 if (new_size != panel->restored_size()) |
472 panel->set_restored_size(new_size); | 476 panel->set_restored_size(new_size); |
473 | 477 |
| 478 // After the restored size has been set, then set the auto-resize |
| 479 // state as appropriate. |
| 480 panel->SetAutoResizable(auto_resize_state == AUTORESIZE_ENABLED); |
| 481 |
474 gfx::Rect bounds = panel->GetBounds(); | 482 gfx::Rect bounds = panel->GetBounds(); |
475 int delta_x = bounds.width() - new_width; | 483 int delta_x = bounds.width() - new_width; |
476 | 484 |
477 // Only need to adjust current bounds if panel is in the dock. | 485 // Only need to adjust current bounds if panel is in the dock. |
478 if (panel->panel_strip() == this) { | 486 if (panel->panel_strip() == this) { |
479 // Only need to adjust bounds height when panel is expanded. | 487 // Only need to adjust bounds height when panel is expanded. |
480 Panel::ExpansionState expansion_state = panel->expansion_state(); | 488 Panel::ExpansionState expansion_state = panel->expansion_state(); |
481 if (new_height != bounds.height() && | 489 if (new_height != bounds.height() && |
482 expansion_state == Panel::EXPANDED) { | 490 expansion_state == Panel::EXPANDED) { |
483 bounds.set_y(bounds.bottom() - new_height); | 491 bounds.set_y(bounds.bottom() - new_height); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 DCHECK(panels_in_temporary_layout_.empty()); | 744 DCHECK(panels_in_temporary_layout_.empty()); |
737 | 745 |
738 // Make a copy of the iterator as closing panels can modify the vector. | 746 // Make a copy of the iterator as closing panels can modify the vector. |
739 Panels panels_copy = panels_; | 747 Panels panels_copy = panels_; |
740 | 748 |
741 // Start from the bottom to avoid reshuffling. | 749 // Start from the bottom to avoid reshuffling. |
742 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 750 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
743 iter != panels_copy.rend(); ++iter) | 751 iter != panels_copy.rend(); ++iter) |
744 (*iter)->Close(); | 752 (*iter)->Close(); |
745 } | 753 } |
OLD | NEW |