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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 GetBottomPositionForExpansionState(expansion_state_to_restore) - height; | 129 GetBottomPositionForExpansionState(expansion_state_to_restore) - height; |
130 panel->SetPanelBounds(gfx::Rect(x, y, width, height)); | 130 panel->SetPanelBounds(gfx::Rect(x, y, width, height)); |
131 | 131 |
132 // Update the minimized state to reflect current titlebar mode. | 132 // Update the minimized state to reflect current titlebar mode. |
133 // Do this AFTER setting panel bounds to avoid an extra bounds change. | 133 // Do this AFTER setting panel bounds to avoid an extra bounds change. |
134 if (panel->expansion_state() != Panel::EXPANDED) | 134 if (panel->expansion_state() != Panel::EXPANDED) |
135 panel->SetExpansionState(expansion_state_to_restore); | 135 panel->SetExpansionState(expansion_state_to_restore); |
136 | 136 |
137 } else { | 137 } else { |
138 // Initialize the newly created panel. Does not bump any panels from strip. | 138 // Initialize the newly created panel. Does not bump any panels from strip. |
139 if (height == 0 && width == 0) { | 139 if (height == 0 && width == 0 && panel_manager_->auto_sizing_enabled()) { |
140 // Auto resizable is enabled only if no initial size is provided. | 140 // Auto resizable is enabled only if no initial size is provided. |
141 panel->SetAutoResizable(true); | 141 panel->SetAutoResizable(true); |
142 } else { | 142 } else { |
143 if (height == 0) | 143 if (height == 0) |
144 height = width / kPanelDefaultWidthToHeightRatio; | 144 height = width / kPanelDefaultWidthToHeightRatio; |
145 if (width == 0) | 145 if (width == 0) |
146 width = height * kPanelDefaultWidthToHeightRatio; | 146 width = height * kPanelDefaultWidthToHeightRatio; |
147 } | 147 } |
148 | 148 |
149 // Constrain sizes to limits. | 149 // Constrain sizes to limits. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 451 } |
452 | 452 |
453 void DockedPanelStrip::DecrementMinimizedPanels() { | 453 void DockedPanelStrip::DecrementMinimizedPanels() { |
454 minimized_panel_count_--; | 454 minimized_panel_count_--; |
455 DCHECK_GE(minimized_panel_count_, 0); | 455 DCHECK_GE(minimized_panel_count_, 0); |
456 if (minimized_panel_count_ == 0) | 456 if (minimized_panel_count_ == 0) |
457 panel_manager_->mouse_watcher()->RemoveObserver(this); | 457 panel_manager_->mouse_watcher()->RemoveObserver(this); |
458 } | 458 } |
459 | 459 |
460 void DockedPanelStrip::ResizePanelWindow( | 460 void DockedPanelStrip::ResizePanelWindow( |
461 Panel* panel, const gfx::Size& preferred_window_size) { | 461 Panel* panel, |
| 462 const gfx::Size& preferred_window_size) { |
462 // The panel width: | 463 // The panel width: |
463 // * cannot grow or shrink to go beyond [min_width, max_width] | 464 // * cannot grow or shrink to go beyond [min_width, max_width] |
464 int new_width = preferred_window_size.width(); | 465 int new_width = preferred_window_size.width(); |
465 if (new_width > panel->max_size().width()) | 466 if (new_width > panel->max_size().width()) |
466 new_width = panel->max_size().width(); | 467 new_width = panel->max_size().width(); |
467 if (new_width < panel->min_size().width()) | 468 if (new_width < panel->min_size().width()) |
468 new_width = panel->min_size().width(); | 469 new_width = panel->min_size().width(); |
469 | 470 |
470 // The panel height: | 471 // The panel height: |
471 // * cannot grow or shrink to go beyond [min_height, max_height] | 472 // * cannot grow or shrink to go beyond [min_height, max_height] |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 DCHECK(panels_in_temporary_layout_.empty()); | 748 DCHECK(panels_in_temporary_layout_.empty()); |
748 | 749 |
749 // Make a copy of the iterator as closing panels can modify the vector. | 750 // Make a copy of the iterator as closing panels can modify the vector. |
750 Panels panels_copy = panels_; | 751 Panels panels_copy = panels_; |
751 | 752 |
752 // Start from the bottom to avoid reshuffling. | 753 // Start from the bottom to avoid reshuffling. |
753 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 754 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
754 iter != panels_copy.rend(); ++iter) | 755 iter != panels_copy.rend(); ++iter) |
755 (*iter)->Close(); | 756 (*iter)->Close(); |
756 } | 757 } |
OLD | NEW |