| OLD | NEW |
| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 AdjustWorkAreaForAutoHidingDesktopBars(); | 98 AdjustWorkAreaForAutoHidingDesktopBars(); |
| 99 | 99 |
| 100 Rearrange(panels_.begin(), StartingRightPosition()); | 100 Rearrange(panels_.begin(), StartingRightPosition()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 Panel* PanelManager::CreatePanel(Browser* browser) { | 103 Panel* PanelManager::CreatePanel(Browser* browser) { |
| 104 // Adjust the width and height to fit into our constraint. | 104 // Adjust the width and height to fit into our constraint. |
| 105 int width = browser->override_bounds().width(); | 105 int width = browser->override_bounds().width(); |
| 106 int height = browser->override_bounds().height(); | 106 int height = browser->override_bounds().height(); |
| 107 | 107 |
| 108 if (width == 0 && height == 0) { | 108 // Auto resizable is enabled only if no initial size is provided. |
| 109 bool auto_resize = (width == 0 && height == 0); |
| 110 |
| 111 if (width == 0) |
| 109 width = kPanelDefaultWidth; | 112 width = kPanelDefaultWidth; |
| 113 if (height == 0) |
| 110 height = kPanelDefaultHeight; | 114 height = kPanelDefaultHeight; |
| 111 } | |
| 112 | 115 |
| 113 int max_panel_width = GetMaxPanelWidth(); | 116 int max_panel_width = GetMaxPanelWidth(); |
| 114 int max_panel_height = GetMaxPanelHeight(); | 117 int max_panel_height = GetMaxPanelHeight(); |
| 115 | 118 |
| 116 if (width < kPanelMinWidth) | 119 if (width < kPanelMinWidth) |
| 117 width = kPanelMinWidth; | 120 width = kPanelMinWidth; |
| 118 else if (width > max_panel_width) | 121 else if (width > max_panel_width) |
| 119 width = max_panel_width; | 122 width = max_panel_width; |
| 120 | 123 |
| 121 if (height < kPanelMinHeight) | 124 if (height < kPanelMinHeight) |
| 122 height = kPanelMinHeight; | 125 height = kPanelMinHeight; |
| 123 else if (height > max_panel_height) | 126 else if (height > max_panel_height) |
| 124 height = max_panel_height; | 127 height = max_panel_height; |
| 125 | 128 |
| 126 int y = adjusted_work_area_.bottom() - height; | 129 int y = adjusted_work_area_.bottom() - height; |
| 127 int x = GetRightMostAvailablePosition() - width; | 130 int x = GetRightMostAvailablePosition() - width; |
| 128 | 131 |
| 129 // Now create the panel with the computed bounds. | 132 // Now create the panel with the computed bounds. |
| 130 Panel* panel = new Panel(browser, gfx::Rect(x, y, width, height)); | 133 Panel* panel = new Panel(browser, |
| 131 panel->SetMaxSize(gfx::Size(max_panel_width, max_panel_height)); | 134 gfx::Rect(x, y, width, height), |
| 135 gfx::Size(kPanelMinWidth, kPanelMinHeight), |
| 136 gfx::Size(max_panel_width, max_panel_height), |
| 137 auto_resize); |
| 132 panels_.push_back(panel); | 138 panels_.push_back(panel); |
| 133 | 139 |
| 134 content::NotificationService::current()->Notify( | 140 content::NotificationService::current()->Notify( |
| 135 chrome::NOTIFICATION_PANEL_ADDED, | 141 chrome::NOTIFICATION_PANEL_ADDED, |
| 136 content::Source<Panel>(panel), | 142 content::Source<Panel>(panel), |
| 137 content::NotificationService::NoDetails()); | 143 content::NotificationService::NoDetails()); |
| 138 | 144 |
| 139 return panel; | 145 return panel; |
| 140 } | 146 } |
| 141 | 147 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 626 |
| 621 // Start from the bottom to avoid reshuffling. | 627 // Start from the bottom to avoid reshuffling. |
| 622 for (Panels::reverse_iterator iter = panels_copy.rbegin(); | 628 for (Panels::reverse_iterator iter = panels_copy.rbegin(); |
| 623 iter != panels_copy.rend(); ++iter) | 629 iter != panels_copy.rend(); ++iter) |
| 624 (*iter)->Close(); | 630 (*iter)->Close(); |
| 625 } | 631 } |
| 626 | 632 |
| 627 bool PanelManager::is_dragging_panel() const { | 633 bool PanelManager::is_dragging_panel() const { |
| 628 return dragging_panel_index_ != kInvalidPanelIndex; | 634 return dragging_panel_index_ != kInvalidPanelIndex; |
| 629 } | 635 } |
| OLD | NEW |