OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 #include "gfx/insets.h" | 11 #include "gfx/insets.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 adding_view_(false) { | 669 adding_view_(false) { |
670 DCHECK(host); | 670 DCHECK(host); |
671 } | 671 } |
672 | 672 |
673 GridLayout::~GridLayout() { | 673 GridLayout::~GridLayout() { |
674 STLDeleteElements(&column_sets_); | 674 STLDeleteElements(&column_sets_); |
675 STLDeleteElements(&view_states_); | 675 STLDeleteElements(&view_states_); |
676 STLDeleteElements(&rows_); | 676 STLDeleteElements(&rows_); |
677 } | 677 } |
678 | 678 |
| 679 // static |
| 680 GridLayout* GridLayout::CreatePanel(View* host) { |
| 681 GridLayout* layout = new GridLayout(host); |
| 682 layout->SetInsets(kPanelVertMargin, kPanelHorizMargin, |
| 683 kPanelVertMargin, kPanelHorizMargin); |
| 684 return layout; |
| 685 } |
| 686 |
679 void GridLayout::SetInsets(int top, int left, int bottom, int right) { | 687 void GridLayout::SetInsets(int top, int left, int bottom, int right) { |
680 top_inset_ = top; | 688 top_inset_ = top; |
681 bottom_inset_ = bottom; | 689 bottom_inset_ = bottom; |
682 left_inset_ = left; | 690 left_inset_ = left; |
683 right_inset_ = right; | 691 right_inset_ = right; |
684 } | 692 } |
685 | 693 |
686 void GridLayout::SetInsets(const gfx::Insets& insets) { | 694 void GridLayout::SetInsets(const gfx::Insets& insets) { |
687 SetInsets(insets.top(), insets.left(), insets.bottom(), insets.right()); | 695 SetInsets(insets.top(), insets.left(), insets.bottom(), insets.right()); |
688 } | 696 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1061 |
1054 ColumnSet* GridLayout::GetLastValidColumnSet() { | 1062 ColumnSet* GridLayout::GetLastValidColumnSet() { |
1055 for (int i = current_row_ - 1; i >= 0; --i) { | 1063 for (int i = current_row_ - 1; i >= 0; --i) { |
1056 if (rows_[i]->column_set()) | 1064 if (rows_[i]->column_set()) |
1057 return rows_[i]->column_set(); | 1065 return rows_[i]->column_set(); |
1058 } | 1066 } |
1059 return NULL; | 1067 return NULL; |
1060 } | 1068 } |
1061 | 1069 |
1062 } // namespace views | 1070 } // namespace views |
1063 | |
1064 views::GridLayout* CreatePanelGridLayout(views::View* host) { | |
1065 views::GridLayout* layout = new views::GridLayout(host); | |
1066 layout->SetInsets(kPanelVertMargin, kPanelHorizMargin, | |
1067 kPanelVertMargin, kPanelHorizMargin); | |
1068 return layout; | |
1069 } | |
OLD | NEW |