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

Side by Side Diff: chrome/browser/ui/panels/docked_panel_strip.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/detached_panel_strip.cc ('k') | chrome/browser/ui/panels/panel.h » ('j') | 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/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/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #if defined(TOOLKIT_GTK) 43 #if defined(TOOLKIT_GTK)
44 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 2000; 44 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 2000;
45 #else 45 #else
46 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 0; 46 const int kDelayBeforeCollapsingFromTitleOnlyStateMs = 0;
47 #endif 47 #endif
48 48
49 // After focus changed, one panel lost active status, another got it, 49 // After focus changed, one panel lost active status, another got it,
50 // we refresh layout with a delay. 50 // we refresh layout with a delay.
51 const int kRefreshLayoutAfterActivePanelChangeDelayMs = 200; // arbitrary 51 const int kRefreshLayoutAfterActivePanelChangeDelayMs = 200; // arbitrary
52 52
53 // The minimum panel width when it is "squeezed" in the docked strip
54 // due to lack of space.
55 const int kMinPanelWidthForDisplay = 26;
56 } // namespace 53 } // namespace
57 54
58 // static 55 // static
59 const int DockedPanelStrip::kPanelMinWidth = 100; 56 // These numbers are semi-arbitrary.
57 // Motivation for 'width' is to make main buttons on the titlebar functional.
58 // Motivation for height is to allow autosized tightly-wrapped panel with a
59 // single line of text - so the height is set to be likely less then a titlebar,
60 // to make sure even small content is tightly wrapped.
61 const int DockedPanelStrip::kPanelMinWidth = 80;
60 const int DockedPanelStrip::kPanelMinHeight = 20; 62 const int DockedPanelStrip::kPanelMinHeight = 20;
61 63
62 DockedPanelStrip::DockedPanelStrip(PanelManager* panel_manager) 64 DockedPanelStrip::DockedPanelStrip(PanelManager* panel_manager)
63 : PanelStrip(PanelStrip::DOCKED), 65 : PanelStrip(PanelStrip::DOCKED),
64 panel_manager_(panel_manager), 66 panel_manager_(panel_manager),
65 minimized_panel_count_(0), 67 minimized_panel_count_(0),
66 are_titlebars_up_(false), 68 are_titlebars_up_(false),
67 minimizing_all_(false), 69 minimizing_all_(false),
68 delayed_titlebar_action_(NO_ACTION), 70 delayed_titlebar_action_(NO_ACTION),
69 titlebar_action_factory_(this), 71 titlebar_action_factory_(this),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 height = kPanelMinHeight; 156 height = kPanelMinHeight;
155 else if (height > max_panel_height) 157 else if (height > max_panel_height)
156 height = max_panel_height; 158 height = max_panel_height;
157 159
158 full_size = gfx::Size(width, height); 160 full_size = gfx::Size(width, height);
159 panel->set_full_size(full_size); 161 panel->set_full_size(full_size);
160 gfx::Point pt = GetDefaultPositionForPanel(full_size); 162 gfx::Point pt = GetDefaultPositionForPanel(full_size);
161 163
162 panel->Initialize(gfx::Rect(pt.x(), pt.y(), width, height)); 164 panel->Initialize(gfx::Rect(pt.x(), pt.y(), width, height));
163 165
166 panel->SetSizeRange(gfx::Size(kPanelMinWidth, kPanelMinHeight),
167 gfx::Size(max_panel_width, max_panel_height));
168
164 InsertExistingPanelAtDefaultPosition(panel, true /*update_bounds*/); 169 InsertExistingPanelAtDefaultPosition(panel, true /*update_bounds*/);
165 } 170 }
166 171
167 void DockedPanelStrip::InsertExistingPanelAtKnownPosition(Panel* panel) { 172 void DockedPanelStrip::InsertExistingPanelAtKnownPosition(Panel* panel) {
168 DCHECK(panel->initialized()); 173 DCHECK(panel->initialized());
169 174
170 int x = panel->GetBounds().x(); 175 int x = panel->GetBounds().x();
171 Panels::iterator iter = panels_.begin(); 176 Panels::iterator iter = panels_.begin();
172 for (; iter != panels_.end(); ++iter) 177 for (; iter != panels_.end(); ++iter)
173 if (x > (*iter)->GetBounds().x()) 178 if (x > (*iter)->GetBounds().x())
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 DCHECK_LE(minimized_panel_count_, num_panels()); 570 DCHECK_LE(minimized_panel_count_, num_panels());
566 } 571 }
567 572
568 void DockedPanelStrip::ResizePanelWindow( 573 void DockedPanelStrip::ResizePanelWindow(
569 Panel* panel, 574 Panel* panel,
570 const gfx::Size& preferred_window_size) { 575 const gfx::Size& preferred_window_size) {
571 DCHECK_EQ(this, panel->panel_strip()); 576 DCHECK_EQ(this, panel->panel_strip());
572 // Make sure the new size does not violate panel's size restrictions. 577 // Make sure the new size does not violate panel's size restrictions.
573 gfx::Size new_size(preferred_window_size.width(), 578 gfx::Size new_size(preferred_window_size.width(),
574 preferred_window_size.height()); 579 preferred_window_size.height());
575 panel->ClampSize(&new_size); 580 new_size = panel->ClampSize(new_size);
576 581
577 if (new_size == panel->full_size()) 582 if (new_size == panel->full_size())
578 return; 583 return;
579 584
580 panel->set_full_size(new_size); 585 panel->set_full_size(new_size);
581 586
582 RefreshLayout(); 587 RefreshLayout();
583 } 588 }
584 589
585 bool DockedPanelStrip::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const { 590 bool DockedPanelStrip::ShouldBringUpTitlebars(int mouse_x, int mouse_y) const {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 849
845 ++num_processed; 850 ++num_processed;
846 } 851 }
847 } 852 }
848 853
849 int DockedPanelStrip::WidthToDisplayPanelInStrip(bool is_for_active_panel, 854 int DockedPanelStrip::WidthToDisplayPanelInStrip(bool is_for_active_panel,
850 double squeeze_factor, 855 double squeeze_factor,
851 int full_width) const { 856 int full_width) const {
852 if (is_for_active_panel) 857 if (is_for_active_panel)
853 return full_width; 858 return full_width;
854 return std::max(kMinPanelWidthForDisplay, 859 return std::max(kPanelMinWidth,
855 static_cast<int>(floor(full_width * squeeze_factor))); 860 static_cast<int>(floor(full_width * squeeze_factor)));
856 } 861 }
857 862
858 void DockedPanelStrip::CloseAll() { 863 void DockedPanelStrip::CloseAll() {
859 // This should only be called at the end of tests to clean up. 864 // This should only be called at the end of tests to clean up.
860 865
861 // Make a copy of the iterator as closing panels can modify the vector. 866 // Make a copy of the iterator as closing panels can modify the vector.
862 Panels panels_copy = panels_; 867 Panels panels_copy = panels_;
863 868
864 // Start from the bottom to avoid reshuffling. 869 // Start from the bottom to avoid reshuffling.
865 for (Panels::reverse_iterator iter = panels_copy.rbegin(); 870 for (Panels::reverse_iterator iter = panels_copy.rbegin();
866 iter != panels_copy.rend(); ++iter) 871 iter != panels_copy.rend(); ++iter)
867 (*iter)->Close(); 872 (*iter)->Close();
868 } 873 }
869 874
870 void DockedPanelStrip::UpdatePanelOnStripChange(Panel* panel) { 875 void DockedPanelStrip::UpdatePanelOnStripChange(Panel* panel) {
871 // Always update limits, even on existing panels, in case the limits changed 876 // Update limits if the panel is still autosizable, in case the limit has
872 // while panel was out of the strip. 877 // changed. If the panel is not autoresizable, then it was resized
873 int max_panel_width = GetMaxPanelWidth(); 878 // by the user or by the app via API.
874 int max_panel_height = GetMaxPanelHeight(); 879 if (panel->auto_resizable()) {
875 panel->SetSizeRange(gfx::Size(kPanelMinWidth, kPanelMinHeight), 880 int max_panel_width = GetMaxPanelWidth();
876 gfx::Size(max_panel_width, max_panel_height)); 881 int max_panel_height = GetMaxPanelHeight();
877 882 panel->SetSizeRange(gfx::Size(kPanelMinWidth, kPanelMinHeight),
883 gfx::Size(max_panel_width, max_panel_height));
884 }
878 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); 885 panel->set_attention_mode(Panel::USE_PANEL_ATTENTION);
879 panel->SetAppIconVisibility(true); 886 panel->SetAppIconVisibility(true);
880 panel->SetAlwaysOnTop(true); 887 panel->SetAlwaysOnTop(true);
881 panel->EnableResizeByMouse(true); 888 panel->EnableResizeByMouse(true);
882 } 889 }
883 890
884 void DockedPanelStrip::OnPanelActiveStateChanged(Panel* panel) { 891 void DockedPanelStrip::OnPanelActiveStateChanged(Panel* panel) {
885 // Refresh layout, but wait till active states settle. 892 // Refresh layout, but wait till active states settle.
886 // This lets us avoid refreshing too many times when one panel loses 893 // This lets us avoid refreshing too many times when one panel loses
887 // focus and another gains it. 894 // focus and another gains it.
888 refresh_action_factory_.InvalidateWeakPtrs(); 895 refresh_action_factory_.InvalidateWeakPtrs();
889 MessageLoop::current()->PostDelayedTask( 896 MessageLoop::current()->PostDelayedTask(
890 FROM_HERE, 897 FROM_HERE,
891 base::Bind(&DockedPanelStrip::RefreshLayout, 898 base::Bind(&DockedPanelStrip::RefreshLayout,
892 refresh_action_factory_.GetWeakPtr()), 899 refresh_action_factory_.GetWeakPtr()),
893 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval( 900 base::TimeDelta::FromMilliseconds(PanelManager::AdjustTimeInterval(
894 kRefreshLayoutAfterActivePanelChangeDelayMs))); 901 kRefreshLayoutAfterActivePanelChangeDelayMs)));
895 } 902 }
896 903
897 bool DockedPanelStrip::HasPanel(Panel* panel) const { 904 bool DockedPanelStrip::HasPanel(Panel* panel) const {
898 return find(panels_.begin(), panels_.end(), panel) != panels_.end(); 905 return find(panels_.begin(), panels_.end(), panel) != panels_.end();
899 } 906 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/detached_panel_strip.cc ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698