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

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

Issue 10260001: Remove panel size limit when user resizes it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 7 months 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
« no previous file with comments | « chrome/browser/ui/panels/panel_resize_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/panel_resize_controller.h" 5 #include "chrome/browser/ui/panels/panel_resize_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_manager.h" 9 #include "chrome/browser/ui/panels/panel_manager.h"
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 if (ResizingLeft(sides_resized_)) { 82 if (ResizingLeft(sides_resized_)) {
83 bounds.set_width(std::max(bounds_at_start_.width() + 83 bounds.set_width(std::max(bounds_at_start_.width() +
84 mouse_location_at_start_.x() - mouse_location.x(), 0)); 84 mouse_location_at_start_.x() - mouse_location.x(), 0));
85 } 85 }
86 if (ResizingTop(sides_resized_)) { 86 if (ResizingTop(sides_resized_)) {
87 bounds.set_height(std::max(bounds_at_start_.height() + 87 bounds.set_height(std::max(bounds_at_start_.height() +
88 mouse_location_at_start_.y() - mouse_location.y(), 0)); 88 mouse_location_at_start_.y() - mouse_location.y(), 0));
89 } 89 }
90 90
91 // Give the panel a chance to adjust the bounds before setting them. 91 // Update the max size of the panel so it's never smaller then the actual
92 gfx::Size size = bounds.size(); 92 // panel's size. Note that even if the user resizes the panel smaller later,
93 resizing_panel_->ClampSize(&size); 93 // the increased max size will still be in effect. Since it's not possible
94 bounds.set_size(size); 94 // currently to switch the panel back to autosizing from user-resizable, it
95 // should not be a problem.
96 gfx::Size max_panel_size = resizing_panel_->max_size();
97 if (max_panel_size.width() < bounds.width())
98 max_panel_size.set_width(bounds.width());
99 if (max_panel_size.height() < bounds.height())
100 max_panel_size.set_height(bounds.height());
101
102 resizing_panel_->SetSizeRange(resizing_panel_->min_size(), max_panel_size);
103
104 // This effectively only clamps using the min size, since the max_size was
105 // updated above.
106 bounds.set_size(resizing_panel_->ClampSize(bounds.size()));
95 107
96 if (ResizingLeft(sides_resized_)) { 108 if (ResizingLeft(sides_resized_)) {
97 bounds.set_x(bounds_at_start_.x() - 109 bounds.set_x(bounds_at_start_.x() -
98 (bounds.width() - bounds_at_start_.width())); 110 (bounds.width() - bounds_at_start_.width()));
99 } 111 }
100 112
101 if (ResizingTop(sides_resized_)) { 113 if (ResizingTop(sides_resized_)) {
102 bounds.set_y(bounds_at_start_.y() - 114 bounds.set_y(bounds_at_start_.y() -
103 (bounds.height() - bounds_at_start_.height())); 115 (bounds.height() - bounds_at_start_.height()));
104 } 116 }
(...skipping 21 matching lines...) Expand all
126 } 138 }
127 139
128 void PanelResizeController::OnPanelClosed(Panel* panel) { 140 void PanelResizeController::OnPanelClosed(Panel* panel) {
129 if (!resizing_panel_) 141 if (!resizing_panel_)
130 return; 142 return;
131 143
132 // If the resizing panel is closed, abort the resize operation. 144 // If the resizing panel is closed, abort the resize operation.
133 if (resizing_panel_ == panel) 145 if (resizing_panel_ == panel)
134 EndResizing(false); 146 EndResizing(false);
135 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_resize_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698