summaryrefslogtreecommitdiffstats
path: root/views/controls/table
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 07:57:10 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 07:57:10 +0000
commitf861719588545d92ba979f491f4cd10cbf544016 (patch)
tree5f5a64d4ba48a8d884ee360a562fb08371404ed6 /views/controls/table
parent84aa957953cf6eb36c4e8886a28aede5fd98f748 (diff)
downloadchromium_src-f861719588545d92ba979f491f4cd10cbf544016.zip
chromium_src-f861719588545d92ba979f491f4cd10cbf544016.tar.gz
chromium_src-f861719588545d92ba979f491f4cd10cbf544016.tar.bz2
Re-land r51526
Auto-size the views version of the options dialog. This adds support for auto-sizing tab controls, adjusts the options dialog to use it and takes care of any fallout due to the new layout handling. Also fixes a couple of small bugs in the views Layout() machinery and sanitizes layouting of options pages. BUG=36497 TEST=unit tests in tabbed_pane_unittest.cc and grid_layout_unittest.cc, as well as checking the options dialog in any supported language. original issuse: http://codereview.chromium.org/2812026/show Review URL: http://codereview.chromium.org/2883022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/table')
-rw-r--r--views/controls/table/table_view.cc14
-rw-r--r--views/controls/table/table_view.h8
2 files changed, 14 insertions, 8 deletions
diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc
index 8b86a6e..7ab4c91 100644
--- a/views/controls/table/table_view.cc
+++ b/views/controls/table/table_view.cc
@@ -64,7 +64,6 @@ TableView::TableView(TableModel* model,
single_selection_(single_selection),
ignore_listview_change_(false),
custom_colors_enabled_(false),
- sized_columns_(false),
autosize_columns_(autosize_columns),
resizable_columns_(resizable_columns),
list_view_(NULL),
@@ -133,10 +132,8 @@ void TableView::DidChangeBounds(const gfx::Rect& previous,
return;
SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(FALSE), 0);
Layout();
- if ((!sized_columns_ || autosize_columns_) && width() > 0) {
- sized_columns_ = true;
+ if (autosize_columns_ && width() > 0)
ResetColumnSizes();
- }
UpdateContentOffset();
SendMessage(list_view_, WM_SETREDRAW, static_cast<WPARAM>(TRUE), 0);
}
@@ -1551,6 +1548,15 @@ gfx::Font TableView::GetAltTextFont() {
return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
}
+void TableView::VisibilityChanged(View* starting_from, bool is_visible) {
+ // GetClientRect as used by ResetColumnSize to obtain the total width
+ // available to the columns only works when the native control is visible, so
+ // update the column sizes in case we become visible. This depends on
+ // VisibilityChanged() being called in post order on the view tree.
+ if (is_visible && autosize_columns_)
+ ResetColumnSizes();
+}
+
//
// TableSelectionIterator
diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h
index f237df2..28d877e 100644
--- a/views/controls/table/table_view.h
+++ b/views/controls/table/table_view.h
@@ -407,6 +407,10 @@ class TableView : public NativeControl,
// Returns the font used for alt text.
gfx::Font GetAltTextFont();
+ // Overriden in order to update the column sizes, which can only be sized
+ // accurately when the native control is available.
+ virtual void VisibilityChanged(View* starting_from, bool is_visible);
+
TableModel* model_;
TableTypes table_type_;
TableViewObserver* table_view_observer_;
@@ -432,10 +436,6 @@ class TableView : public NativeControl,
// Reflects the value passed to SetCustomColorsEnabled.
bool custom_colors_enabled_;
- // Whether or not the columns have been sized in the ListView. This is
- // set to true the first time Layout() is invoked and we have a valid size.
- bool sized_columns_;
-
// Whether or not columns should automatically be resized to fill the
// the available width when the list view is resized.
bool autosize_columns_;