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

Side by Side Diff: views/grid_layout.cc

Issue 2812026: Auto-size the views version of the options dialog. (Closed)
Patch Set: Fix autosizing issue with gtk pref pages in chromeos options dialog. Created 10 years, 5 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
« no previous file with comments | « views/grid_layout.h ('k') | views/grid_layout_unittest.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/grid_layout.h" 5 #include "views/grid_layout.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 837 }
838 838
839 void GridLayout::SizeRowsAndColumns(bool layout, int width, int height, 839 void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
840 gfx::Size* pref) { 840 gfx::Size* pref) {
841 // Make sure the master columns have been calculated. 841 // Make sure the master columns have been calculated.
842 CalculateMasterColumnsIfNecessary(); 842 CalculateMasterColumnsIfNecessary();
843 pref->SetSize(0, 0); 843 pref->SetSize(0, 0);
844 if (rows_.empty()) 844 if (rows_.empty())
845 return; 845 return;
846 846
847 // Calculate the size of each of the columns. Some views preferred heights are 847 // Calculate the preferred width of each of the columns. Some views'
848 // derived from their width, as such we need to calculate the size of the 848 // preferred heights are derived from their width, as such we need to
849 // columns first. 849 // calculate the size of the columns first.
850 for (std::vector<ColumnSet*>::iterator i = column_sets_.begin(); 850 for (std::vector<ColumnSet*>::iterator i = column_sets_.begin();
851 i != column_sets_.end(); ++i) { 851 i != column_sets_.end(); ++i) {
852 (*i)->CalculateSize(); 852 (*i)->CalculateSize();
853 if (layout || width > 0) {
854 // We're doing a layout, divy up any extra space.
855 (*i)->Resize(width - (*i)->LayoutWidth() - left_inset_ - right_inset_);
856 // And reset the x coordinates.
857 (*i)->ResetColumnXCoordinates();
858 }
859 pref->set_width(std::max(pref->width(), (*i)->LayoutWidth())); 853 pref->set_width(std::max(pref->width(), (*i)->LayoutWidth()));
860 } 854 }
861 pref->set_width(pref->width() + left_inset_ + right_inset_); 855 pref->set_width(pref->width() + left_inset_ + right_inset_);
862 856
857 // Go over the columns again and set them all to the size we settled for.
858 width = width ? width : pref->width();
859 for (std::vector<ColumnSet*>::iterator i = column_sets_.begin();
860 i != column_sets_.end(); ++i) {
861 // We're doing a layout, divy up any extra space.
862 (*i)->Resize(width - (*i)->LayoutWidth() - left_inset_ - right_inset_);
863 // And reset the x coordinates.
864 (*i)->ResetColumnXCoordinates();
865 }
866
863 // Reset the height of each row. 867 // Reset the height of each row.
864 LayoutElement::ResetSizes(&rows_); 868 LayoutElement::ResetSizes(&rows_);
865 869
866 // Do the following: 870 // Do the following:
867 // . If the view is aligned along it's baseline, obtain the baseline from the 871 // . If the view is aligned along it's baseline, obtain the baseline from the
868 // view and update the rows ascent/descent. 872 // view and update the rows ascent/descent.
869 // . Reset the remaining_height of each view state. 873 // . Reset the remaining_height of each view state.
870 // . If the width the view will be given is different than it's pref, ask 874 // . If the width the view will be given is different than it's pref, ask
871 // for the height given a particularly width. 875 // for the height given a particularly width.
872 for (std::vector<ViewState*>::iterator i= view_states_.begin(); 876 for (std::vector<ViewState*>::iterator i= view_states_.begin();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1060 }
1057 1061
1058 } // namespace views 1062 } // namespace views
1059 1063
1060 views::GridLayout* CreatePanelGridLayout(views::View* host) { 1064 views::GridLayout* CreatePanelGridLayout(views::View* host) {
1061 views::GridLayout* layout = new views::GridLayout(host); 1065 views::GridLayout* layout = new views::GridLayout(host);
1062 layout->SetInsets(kPanelVertMargin, kPanelHorizMargin, 1066 layout->SetInsets(kPanelVertMargin, kPanelHorizMargin,
1063 kPanelVertMargin, kPanelHorizMargin); 1067 kPanelVertMargin, kPanelHorizMargin);
1064 return layout; 1068 return layout;
1065 } 1069 }
1066
OLDNEW
« no previous file with comments | « views/grid_layout.h ('k') | views/grid_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698