| OLD | NEW |
| 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 "ui/views/controls/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 int TableView::ViewToModel(int view_index) const { | 298 int TableView::ViewToModel(int view_index) const { |
| 299 if (!is_sorted()) | 299 if (!is_sorted()) |
| 300 return view_index; | 300 return view_index; |
| 301 DCHECK_GE(view_index, 0) << " negative view_index " << view_index; | 301 DCHECK_GE(view_index, 0) << " negative view_index " << view_index; |
| 302 DCHECK_LT(view_index, RowCount()) << " out of bounds view_index " << | 302 DCHECK_LT(view_index, RowCount()) << " out of bounds view_index " << |
| 303 view_index; | 303 view_index; |
| 304 return view_to_model_[view_index]; | 304 return view_to_model_[view_index]; |
| 305 } | 305 } |
| 306 | 306 |
| 307 void TableView::Layout() { | 307 void TableView::Layout() { |
| 308 // parent()->parent() is the scrollview. When its width changes we force | 308 // When the scroll view width changes, recalculate column sizes. |
| 309 // recalculating column sizes. | 309 ScrollView* scroll_view = EnclosingScrollView(); |
| 310 View* scroll_view = parent() ? parent()->parent() : NULL; | |
| 311 if (scroll_view) { | 310 if (scroll_view) { |
| 312 const int scroll_view_width = scroll_view->GetContentsBounds().width(); | 311 const int scroll_view_width = scroll_view->GetContentsBounds().width(); |
| 313 if (scroll_view_width != last_parent_width_) { | 312 if (scroll_view_width != last_parent_width_) { |
| 314 last_parent_width_ = scroll_view_width; | 313 last_parent_width_ = scroll_view_width; |
| 315 if (!in_set_visible_column_width_) { | 314 if (!in_set_visible_column_width_) { |
| 316 // Layout to the parent (the Viewport), which differs from | 315 // Layout to the visible width (the Viewport), which differs from |
| 317 // |scroll_view_width| when scrollbars are present. | 316 // |scroll_view_width| when scrollbars are present. |
| 318 layout_width_ = parent()->width(); | 317 layout_width_ = scroll_view->GetVisibleRect().width(); |
| 319 UpdateVisibleColumnSizes(); | 318 UpdateVisibleColumnSizes(); |
| 320 } | 319 } |
| 321 } | 320 } |
| 322 } | 321 } |
| 323 // We have to override Layout like this since we're contained in a ScrollView. | 322 // We have to override Layout like this since we're contained in a ScrollView. |
| 324 gfx::Size pref = GetPreferredSize(); | 323 gfx::Size pref = GetPreferredSize(); |
| 325 int width = pref.width(); | 324 int width = pref.width(); |
| 326 int height = pref.height(); | 325 int height = pref.height(); |
| 327 if (parent()) { | 326 if (parent()) { |
| 328 width = std::max(parent()->width(), width); | 327 width = std::max(parent()->width(), width); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 if (tooltip) | 951 if (tooltip) |
| 953 *tooltip = text; | 952 *tooltip = text; |
| 954 if (tooltip_origin) { | 953 if (tooltip_origin) { |
| 955 tooltip_origin->SetPoint(cell_bounds.x(), | 954 tooltip_origin->SetPoint(cell_bounds.x(), |
| 956 cell_bounds.y() + kTextVerticalPadding); | 955 cell_bounds.y() + kTextVerticalPadding); |
| 957 } | 956 } |
| 958 return true; | 957 return true; |
| 959 } | 958 } |
| 960 | 959 |
| 961 } // namespace views | 960 } // namespace views |
| OLD | NEW |