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

Side by Side Diff: chrome/browser/ui/panels/panel_manager.cc

Issue 8602007: Panels: Disable auto-resize if initial size is specified during creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 AdjustWorkAreaForAutoHidingDesktopBars(); 93 AdjustWorkAreaForAutoHidingDesktopBars();
94 94
95 Rearrange(panels_.begin(), StartingRightPosition()); 95 Rearrange(panels_.begin(), StartingRightPosition());
96 } 96 }
97 97
98 Panel* PanelManager::CreatePanel(Browser* browser) { 98 Panel* PanelManager::CreatePanel(Browser* browser) {
99 // Adjust the width and height to fit into our constraint. 99 // Adjust the width and height to fit into our constraint.
100 int width = browser->override_bounds().width(); 100 int width = browser->override_bounds().width();
101 int height = browser->override_bounds().height(); 101 int height = browser->override_bounds().height();
102 102
103 if (width == 0 && height == 0) { 103 // Auto resizable is enabled only if no initial size is provided.
104 bool auto_resize = !(width || height);
Dmitry Titov 2011/11/18 23:00:34 I think the coding style actually prefers this sty
jianli 2011/11/18 23:03:32 I find it more readable if we say "width = 0 && he
jennb 2011/11/18 23:26:00 Done.
105
106 if (width == 0)
104 width = kPanelDefaultWidth; 107 width = kPanelDefaultWidth;
108 if (height == 0)
105 height = kPanelDefaultHeight; 109 height = kPanelDefaultHeight;
106 }
107 110
108 int max_panel_width = GetMaxPanelWidth(); 111 int max_panel_width = GetMaxPanelWidth();
109 int max_panel_height = GetMaxPanelHeight(); 112 int max_panel_height = GetMaxPanelHeight();
110 113
111 if (width < kPanelMinWidth) 114 if (width < kPanelMinWidth)
112 width = kPanelMinWidth; 115 width = kPanelMinWidth;
113 else if (width > max_panel_width) 116 else if (width > max_panel_width)
114 width = max_panel_width; 117 width = max_panel_width;
115 118
116 if (height < kPanelMinHeight) 119 if (height < kPanelMinHeight)
117 height = kPanelMinHeight; 120 height = kPanelMinHeight;
118 else if (height > max_panel_height) 121 else if (height > max_panel_height)
119 height = max_panel_height; 122 height = max_panel_height;
120 123
121 int y = adjusted_work_area_.bottom() - height; 124 int y = adjusted_work_area_.bottom() - height;
122 int x = GetRightMostAvailablePosition() - width; 125 int x = GetRightMostAvailablePosition() - width;
123 126
124 // Now create the panel with the computed bounds. 127 // Now create the panel with the computed bounds.
125 Panel* panel = new Panel(browser, gfx::Rect(x, y, width, height)); 128 Panel* panel = new Panel(browser, gfx::Rect(x, y, width, height));
126 panel->SetMaxSize(gfx::Size(max_panel_width, max_panel_height)); 129 panel->SetMaxSize(gfx::Size(max_panel_width, max_panel_height));
130 panel->SetMinSize(gfx::Size(kPanelMinWidth, kPanelMinHeight));
131 panel->SetAutoResizable(auto_resize);
127 panels_.push_back(panel); 132 panels_.push_back(panel);
128 133
129 content::NotificationService::current()->Notify( 134 content::NotificationService::current()->Notify(
130 chrome::NOTIFICATION_PANEL_ADDED, 135 chrome::NOTIFICATION_PANEL_ADDED,
131 content::Source<Panel>(panel), 136 content::Source<Panel>(panel),
132 content::NotificationService::NoDetails()); 137 content::NotificationService::NoDetails());
133 138
134 return panel; 139 return panel;
135 } 140 }
136 141
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 620
616 // Start from the bottom to avoid reshuffling. 621 // Start from the bottom to avoid reshuffling.
617 for (Panels::reverse_iterator iter = panels_copy.rbegin(); 622 for (Panels::reverse_iterator iter = panels_copy.rbegin();
618 iter != panels_copy.rend(); ++iter) 623 iter != panels_copy.rend(); ++iter)
619 (*iter)->Close(); 624 (*iter)->Close();
620 } 625 }
621 626
622 bool PanelManager::is_dragging_panel() const { 627 bool PanelManager::is_dragging_panel() const {
623 return dragging_panel_index_ != kInvalidPanelIndex; 628 return dragging_panel_index_ != kInvalidPanelIndex;
624 } 629 }
OLDNEW
« chrome/browser/ui/panels/panel.cc ('K') | « chrome/browser/ui/panels/panel_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698