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 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 292 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) { |
453 // The panel width: | 454 // The panel width: |
454 // * cannot grow or shrink to go beyond [min_width, max_width] | 455 // * cannot grow or shrink to go beyond [min_width, max_width] |
455 int new_width = preferred_window_size.width(); | 456 int new_width = preferred_window_size.width(); |
456 if (new_width > panel->max_size().width()) | 457 if (new_width > panel->max_size().width()) |
457 new_width = panel->max_size().width(); | 458 new_width = panel->max_size().width(); |
458 if (new_width < panel->min_size().width()) | 459 if (new_width < panel->min_size().width()) |
459 new_width = panel->min_size().width(); | 460 new_width = panel->min_size().width(); |
460 | 461 |
461 // The panel height: | 462 // The panel height: |
462 // * cannot grow or shrink to go beyond [min_height, max_height] | 463 // * cannot grow or shrink to go beyond [min_height, max_height] |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 DCHECK(panels_in_temporary_layout_.empty()); | 737 DCHECK(panels_in_temporary_layout_.empty()); |
737 | 738 |
738 // Make a copy of the iterator as closing panels can modify the vector. | 739 // Make a copy of the iterator as closing panels can modify the vector. |
739 Panels panels_copy = panels_; | 740 Panels panels_copy = panels_; |
740 | 741 |
741 // Start from the bottom to avoid reshuffling. | 742 // Start from the bottom to avoid reshuffling. |
742 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 743 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
743 iter != panels_copy.rend(); ++iter) | 744 iter != panels_copy.rend(); ++iter) |
744 (*iter)->Close(); | 745 (*iter)->Close(); |
745 } | 746 } |
OLD | NEW |