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

Side by Side Diff: ui/views/layout/grid_layout.h

Issue 2859193004: Remove GridLayout::SetInsets in favor of an empty border on the host. (Closed)
Patch Set: edits Created 3 years, 7 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
OLDNEW
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 #ifndef UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ 5 #ifndef UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
6 #define UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ 6 #define UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "ui/gfx/geometry/insets.h" 14 #include "ui/gfx/geometry/insets.h"
sky 2017/05/05 14:36:39 If you can, remove this include.
Bret 2017/05/06 00:36:43 Done.
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 #include "ui/views/layout/layout_manager.h" 16 #include "ui/views/layout/layout_manager.h"
17 17
18 // GridLayout is a LayoutManager that positions child Views in a grid. You 18 // GridLayout is a LayoutManager that positions child Views in a grid. You
19 // define the structure of the Grid first, then add the Views. 19 // define the structure of the Grid first, then add the Views.
20 // The following creates a trivial grid with two columns separated by 20 // The following creates a trivial grid with two columns separated by
21 // a column with padding: 21 // a column with padding:
22 // ColumnSet* columns = layout->AddColumnSet(0); // Give this column set an 22 // ColumnSet* columns = layout->AddColumnSet(0); // Give this column set an
23 // // identifier of 0. 23 // // identifier of 0.
24 // columns->AddColumn(FILL, // Views are horizontally resized to fill column. 24 // columns->AddColumn(FILL, // Views are horizontally resized to fill column.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // The column size is fixed. 97 // The column size is fixed.
98 FIXED, 98 FIXED,
99 99
100 // The preferred size of the view is used to determine the column size. 100 // The preferred size of the view is used to determine the column size.
101 USE_PREF 101 USE_PREF
102 }; 102 };
103 103
104 explicit GridLayout(View* host); 104 explicit GridLayout(View* host);
105 ~GridLayout() override; 105 ~GridLayout() override;
106 106
107 // Creates a GridLayout with kPanel*Margin insets. 107 // Creates a GridLayout, assigns it as the LayoutManager of |host|, and gives
108 // it a INSETS_PANEL-sized padding border.
108 static GridLayout* CreatePanel(View* host); 109 static GridLayout* CreatePanel(View* host);
109 110
110 // Sets the insets. All views are placed relative to these offsets.
111 void SetInsets(int top, int left, int bottom, int right);
112 void SetInsets(const gfx::Insets& insets);
113
114 // Creates a new column set with the specified id and returns it. 111 // Creates a new column set with the specified id and returns it.
115 // The id is later used when starting a new row. 112 // The id is later used when starting a new row.
116 // GridLayout takes ownership of the ColumnSet and will delete it when 113 // GridLayout takes ownership of the ColumnSet and will delete it when
117 // the GridLayout is deleted. 114 // the GridLayout is deleted.
118 ColumnSet* AddColumnSet(int id); 115 ColumnSet* AddColumnSet(int id);
119 116
120 // Returns the column set for the specified id, or NULL if one doesn't exist. 117 // Returns the column set for the specified id, or NULL if one doesn't exist.
121 ColumnSet* GetColumnSet(int id); 118 ColumnSet* GetColumnSet(int id);
122 119
123 // Adds a padding row. Padding rows typically don't have any views, and 120 // Adds a padding row. Padding rows typically don't have any views, and
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 229
233 // Current row. 230 // Current row.
234 int current_row_; 231 int current_row_;
235 232
236 // Current column. 233 // Current column.
237 int next_column_; 234 int next_column_;
238 235
239 // Column set for the current row. This is null for padding rows. 236 // Column set for the current row. This is null for padding rows.
240 ColumnSet* current_row_col_set_; 237 ColumnSet* current_row_col_set_;
241 238
242 // Insets.
243 gfx::Insets insets_;
244
245 // Set to true when adding a View. 239 // Set to true when adding a View.
246 bool adding_view_; 240 bool adding_view_;
247 241
248 // ViewStates. This is ordered by row_span in ascending order. 242 // ViewStates. This is ordered by row_span in ascending order.
249 mutable std::vector<std::unique_ptr<ViewState>> view_states_; 243 mutable std::vector<std::unique_ptr<ViewState>> view_states_;
250 244
251 // ColumnSets. 245 // ColumnSets.
252 mutable std::vector<std::unique_ptr<ColumnSet>> column_sets_; 246 mutable std::vector<std::unique_ptr<ColumnSet>> column_sets_;
253 247
254 // Rows. 248 // Rows.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // The master column of those columns that are linked. See Column 368 // The master column of those columns that are linked. See Column
375 // for a description of what the master column is. 369 // for a description of what the master column is.
376 std::vector<Column*> master_columns_; 370 std::vector<Column*> master_columns_;
377 371
378 DISALLOW_COPY_AND_ASSIGN(ColumnSet); 372 DISALLOW_COPY_AND_ASSIGN(ColumnSet);
379 }; 373 };
380 374
381 } // namespace views 375 } // namespace views
382 376
383 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ 377 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698