| 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/layout/grid_layout.h" | 5 #include "ui/views/layout/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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return this; | 229 return this; |
| 230 } | 230 } |
| 231 return master_column_->GetLastMasterColumn(); | 231 return master_column_->GetLastMasterColumn(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void Column::UnifySameSizedColumnSizes() { | 234 void Column::UnifySameSizedColumnSizes() { |
| 235 DCHECK(master_column_ == this); | 235 DCHECK(master_column_ == this); |
| 236 | 236 |
| 237 // Accumulate the size first. | 237 // Accumulate the size first. |
| 238 int size = 0; | 238 int size = 0; |
| 239 for (auto column : same_size_columns_) | 239 for (auto* column : same_size_columns_) |
| 240 size = std::max(size, column->Size()); | 240 size = std::max(size, column->Size()); |
| 241 | 241 |
| 242 // Then apply it. | 242 // Then apply it. |
| 243 for (auto column : same_size_columns_) | 243 for (auto* column : same_size_columns_) |
| 244 column->SetSize(size); | 244 column->SetSize(size); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void Column::AdjustSize(int size) { | 247 void Column::AdjustSize(int size) { |
| 248 if (size_type_ == GridLayout::USE_PREF) | 248 if (size_type_ == GridLayout::USE_PREF) |
| 249 LayoutElement::AdjustSize(size); | 249 LayoutElement::AdjustSize(size); |
| 250 } | 250 } |
| 251 | 251 |
| 252 // Row ------------------------------------------------------------- | 252 // Row ------------------------------------------------------------- |
| 253 | 253 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 master_columns_.push_back(master_column); | 489 master_columns_.push_back(master_column); |
| 490 } | 490 } |
| 491 // At this point, GetLastMasterColumn may not == master_column | 491 // At this point, GetLastMasterColumn may not == master_column |
| 492 // (may have to go through a few Columns)_. Reset master_column to | 492 // (may have to go through a few Columns)_. Reset master_column to |
| 493 // avoid hops. | 493 // avoid hops. |
| 494 column->master_column_ = master_column; | 494 column->master_column_ = master_column; |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| 498 void ColumnSet::UnifySameSizedColumnSizes() { | 498 void ColumnSet::UnifySameSizedColumnSizes() { |
| 499 for (auto column : master_columns_) | 499 for (auto* column : master_columns_) |
| 500 column->UnifySameSizedColumnSizes(); | 500 column->UnifySameSizedColumnSizes(); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void ColumnSet::UpdateRemainingWidth(ViewState* view_state) { | 503 void ColumnSet::UpdateRemainingWidth(ViewState* view_state) { |
| 504 for (int i = view_state->start_col, | 504 for (int i = view_state->start_col, |
| 505 max_col = view_state->start_col + view_state->col_span; | 505 max_col = view_state->start_col + view_state->col_span; |
| 506 i < max_col; ++i) { | 506 i < max_col; ++i) { |
| 507 view_state->remaining_width -= columns_[i]->Size(); | 507 view_state->remaining_width -= columns_[i]->Size(); |
| 508 } | 508 } |
| 509 } | 509 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return LayoutElement::TotalSize(start_col, col_span, &columns_); | 576 return LayoutElement::TotalSize(start_col, col_span, &columns_); |
| 577 } | 577 } |
| 578 | 578 |
| 579 void ColumnSet::ResetColumnXCoordinates() { | 579 void ColumnSet::ResetColumnXCoordinates() { |
| 580 LayoutElement::CalculateLocationsFromSize(&columns_); | 580 LayoutElement::CalculateLocationsFromSize(&columns_); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void ColumnSet::CalculateSize() { | 583 void ColumnSet::CalculateSize() { |
| 584 gfx::Size pref; | 584 gfx::Size pref; |
| 585 // Reset the preferred and remaining sizes. | 585 // Reset the preferred and remaining sizes. |
| 586 for (const auto& view_state : view_states_) { | 586 for (auto* view_state : view_states_) { |
| 587 if (!view_state->pref_width_fixed || !view_state->pref_height_fixed) { | 587 if (!view_state->pref_width_fixed || !view_state->pref_height_fixed) { |
| 588 pref = view_state->view->GetPreferredSize(); | 588 pref = view_state->view->GetPreferredSize(); |
| 589 if (!view_state->pref_width_fixed) | 589 if (!view_state->pref_width_fixed) |
| 590 view_state->pref_width = pref.width(); | 590 view_state->pref_width = pref.width(); |
| 591 if (!view_state->pref_height_fixed) | 591 if (!view_state->pref_height_fixed) |
| 592 view_state->pref_height = pref.height(); | 592 view_state->pref_height = pref.height(); |
| 593 } | 593 } |
| 594 view_state->remaining_width = pref.width(); | 594 view_state->remaining_width = pref.width(); |
| 595 view_state->remaining_height = pref.height(); | 595 view_state->remaining_height = pref.height(); |
| 596 } | 596 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 | 1020 |
| 1021 ColumnSet* GridLayout::GetLastValidColumnSet() { | 1021 ColumnSet* GridLayout::GetLastValidColumnSet() { |
| 1022 for (int i = current_row_ - 1; i >= 0; --i) { | 1022 for (int i = current_row_ - 1; i >= 0; --i) { |
| 1023 if (rows_[i]->column_set()) | 1023 if (rows_[i]->column_set()) |
| 1024 return rows_[i]->column_set(); | 1024 return rows_[i]->column_set(); |
| 1025 } | 1025 } |
| 1026 return nullptr; | 1026 return nullptr; |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 } // namespace views | 1029 } // namespace views |
| OLD | NEW |