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

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: missed a merge problem 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
« no previous file with comments | « ui/message_center/views/message_center_view_unittest.cc ('k') | ui/views/layout/grid_layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
15 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
16 #include "ui/views/layout/layout_manager.h" 15 #include "ui/views/layout/layout_manager.h"
17 16
18 // GridLayout is a LayoutManager that positions child Views in a grid. You 17 // GridLayout is a LayoutManager that positions child Views in a grid. You
19 // define the structure of the Grid first, then add the Views. 18 // define the structure of the Grid first, then add the Views.
20 // The following creates a trivial grid with two columns separated by 19 // The following creates a trivial grid with two columns separated by
21 // a column with padding: 20 // a column with padding:
22 // ColumnSet* columns = layout->AddColumnSet(0); // Give this column set an 21 // ColumnSet* columns = layout->AddColumnSet(0); // Give this column set an
23 // // identifier of 0. 22 // // identifier of 0.
24 // columns->AddColumn(FILL, // Views are horizontally resized to fill column. 23 // 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. 96 // The column size is fixed.
98 FIXED, 97 FIXED,
99 98
100 // The preferred size of the view is used to determine the column size. 99 // The preferred size of the view is used to determine the column size.
101 USE_PREF 100 USE_PREF
102 }; 101 };
103 102
104 explicit GridLayout(View* host); 103 explicit GridLayout(View* host);
105 ~GridLayout() override; 104 ~GridLayout() override;
106 105
107 // Creates a GridLayout with kPanel*Margin insets. 106 // Creates a GridLayout, assigns it as the LayoutManager of |host|, and gives
107 // it a INSETS_PANEL-sized padding border.
108 static GridLayout* CreatePanel(View* host); 108 static GridLayout* CreatePanel(View* host);
109 109
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. 110 // Creates a new column set with the specified id and returns it.
115 // The id is later used when starting a new row. 111 // The id is later used when starting a new row.
116 // GridLayout takes ownership of the ColumnSet and will delete it when 112 // GridLayout takes ownership of the ColumnSet and will delete it when
117 // the GridLayout is deleted. 113 // the GridLayout is deleted.
118 ColumnSet* AddColumnSet(int id); 114 ColumnSet* AddColumnSet(int id);
119 115
120 // Returns the column set for the specified id, or NULL if one doesn't exist. 116 // Returns the column set for the specified id, or NULL if one doesn't exist.
121 ColumnSet* GetColumnSet(int id); 117 ColumnSet* GetColumnSet(int id);
122 118
123 // Adds a padding row. Padding rows typically don't have any views, and 119 // 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 228
233 // Current row. 229 // Current row.
234 int current_row_; 230 int current_row_;
235 231
236 // Current column. 232 // Current column.
237 int next_column_; 233 int next_column_;
238 234
239 // Column set for the current row. This is null for padding rows. 235 // Column set for the current row. This is null for padding rows.
240 ColumnSet* current_row_col_set_; 236 ColumnSet* current_row_col_set_;
241 237
242 // Insets.
243 gfx::Insets insets_;
244
245 // Set to true when adding a View. 238 // Set to true when adding a View.
246 bool adding_view_; 239 bool adding_view_;
247 240
248 // ViewStates. This is ordered by row_span in ascending order. 241 // ViewStates. This is ordered by row_span in ascending order.
249 mutable std::vector<std::unique_ptr<ViewState>> view_states_; 242 mutable std::vector<std::unique_ptr<ViewState>> view_states_;
250 243
251 // ColumnSets. 244 // ColumnSets.
252 mutable std::vector<std::unique_ptr<ColumnSet>> column_sets_; 245 mutable std::vector<std::unique_ptr<ColumnSet>> column_sets_;
253 246
254 // Rows. 247 // 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 367 // The master column of those columns that are linked. See Column
375 // for a description of what the master column is. 368 // for a description of what the master column is.
376 std::vector<Column*> master_columns_; 369 std::vector<Column*> master_columns_;
377 370
378 DISALLOW_COPY_AND_ASSIGN(ColumnSet); 371 DISALLOW_COPY_AND_ASSIGN(ColumnSet);
379 }; 372 };
380 373
381 } // namespace views 374 } // namespace views
382 375
383 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ 376 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view_unittest.cc ('k') | ui/views/layout/grid_layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698