| 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 #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> |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 int fixed_width, | 293 int fixed_width, |
| 294 int min_width); | 294 int min_width); |
| 295 | 295 |
| 296 // Forces the specified columns to have the same size. The size of | 296 // Forces the specified columns to have the same size. The size of |
| 297 // linked columns is that of the max of the specified columns. This | 297 // linked columns is that of the max of the specified columns. This |
| 298 // must end with -1. For example, the following forces the first and | 298 // must end with -1. For example, the following forces the first and |
| 299 // second column to have the same size: | 299 // second column to have the same size: |
| 300 // LinkColumnSizes(0, 1, -1); | 300 // LinkColumnSizes(0, 1, -1); |
| 301 void LinkColumnSizes(int first, ...); | 301 void LinkColumnSizes(int first, ...); |
| 302 | 302 |
| 303 // When sizing linked columns, columns wider than |size_limit| are ignored. |
| 304 void set_linked_column_size_limit(int size_limit) { |
| 305 linked_column_size_limit_ = size_limit; |
| 306 } |
| 307 |
| 303 // ID of this ColumnSet. | 308 // ID of this ColumnSet. |
| 304 int id() const { return id_; } | 309 int id() const { return id_; } |
| 305 | 310 |
| 306 int num_columns() const { return static_cast<int>(columns_.size()); } | 311 int num_columns() const { return static_cast<int>(columns_.size()); } |
| 307 | 312 |
| 308 private: | 313 private: |
| 309 friend class GridLayout; | 314 friend class GridLayout; |
| 310 | 315 |
| 311 explicit ColumnSet(int id); | 316 explicit ColumnSet(int id); |
| 312 | 317 |
| 313 void AddColumn(GridLayout::Alignment h_align, | 318 void AddColumn(GridLayout::Alignment h_align, |
| 314 GridLayout::Alignment v_align, | 319 GridLayout::Alignment v_align, |
| 315 float resize_percent, | 320 float resize_percent, |
| 316 GridLayout::SizeType size_type, | 321 GridLayout::SizeType size_type, |
| 317 int fixed_width, | 322 int fixed_width, |
| 318 int min_width, | 323 int min_width, |
| 319 bool is_padding); | 324 bool is_padding); |
| 320 | 325 |
| 321 void AddViewState(ViewState* view_state); | 326 void AddViewState(ViewState* view_state); |
| 322 | 327 |
| 323 // Set description of these. | 328 // Set description of these. |
| 324 void CalculateMasterColumns(); | 329 void CalculateMasterColumns(); |
| 325 void AccumulateMasterColumns(); | 330 void AccumulateMasterColumns(); |
| 326 | 331 |
| 327 // Sets the size of each linked column to be the same. | 332 // Sets the size of each linked column to be the same. |
| 328 void UnifySameSizedColumnSizes(); | 333 void UnifyLinkedColumnSizes(); |
| 329 | 334 |
| 330 // Updates the remaining width field of the ViewState from that of the | 335 // Updates the remaining width field of the ViewState from that of the |
| 331 // columns the view spans. | 336 // columns the view spans. |
| 332 void UpdateRemainingWidth(ViewState* view_state); | 337 void UpdateRemainingWidth(ViewState* view_state); |
| 333 | 338 |
| 334 // Makes sure the columns touched by view state are big enough for the | 339 // Makes sure the columns touched by view state are big enough for the |
| 335 // view. | 340 // view. |
| 336 void DistributeRemainingWidth(ViewState* view_state); | 341 void DistributeRemainingWidth(ViewState* view_state); |
| 337 | 342 |
| 338 // Returns the total size needed for this ColumnSet. | 343 // Returns the total size needed for this ColumnSet. |
| 339 int LayoutWidth(); | 344 int LayoutWidth(); |
| 340 | 345 |
| 341 // Returns the width of the specified columns. | 346 // Returns the width of the specified columns. |
| 342 int GetColumnWidth(int start_col, int col_span); | 347 int GetColumnWidth(int start_col, int col_span); |
| 343 | 348 |
| 344 // Updates the x coordinate of each column from the previous ones. | 349 // Updates the x coordinate of each column from the previous ones. |
| 345 // NOTE: this doesn't include the insets. | 350 // NOTE: this doesn't include the insets. |
| 346 void ResetColumnXCoordinates(); | 351 void ResetColumnXCoordinates(); |
| 347 | 352 |
| 348 // Calculate the preferred width of each view in this column set, as well | 353 // Calculate the preferred width of each view in this column set, as well |
| 349 // as updating the remaining_width. | 354 // as updating the remaining_width. |
| 350 void CalculateSize(); | 355 void CalculateSize(); |
| 351 | 356 |
| 352 // Distributes delta among the resizable columns. | 357 // Distributes delta among the resizable columns. |
| 353 void Resize(int delta); | 358 void Resize(int delta); |
| 354 | 359 |
| 355 // ID for this columnset. | 360 // ID for this columnset. |
| 356 const int id_; | 361 const int id_; |
| 357 | 362 |
| 363 // Columns wider than this limit will be ignored when computing linked |
| 364 // columns' sizes. |
| 365 int linked_column_size_limit_; |
| 366 |
| 358 // The columns. | 367 // The columns. |
| 359 std::vector<std::unique_ptr<Column>> columns_; | 368 std::vector<std::unique_ptr<Column>> columns_; |
| 360 | 369 |
| 361 // The ViewStates. This is sorted based on column_span in ascending | 370 // The ViewStates. This is sorted based on column_span in ascending |
| 362 // order. | 371 // order. |
| 363 std::vector<ViewState*> view_states_; | 372 std::vector<ViewState*> view_states_; |
| 364 | 373 |
| 365 // The master column of those columns that are linked. See Column | 374 // The master column of those columns that are linked. See Column |
| 366 // for a description of what the master column is. | 375 // for a description of what the master column is. |
| 367 std::vector<Column*> master_columns_; | 376 std::vector<Column*> master_columns_; |
| 368 | 377 |
| 369 DISALLOW_COPY_AND_ASSIGN(ColumnSet); | 378 DISALLOW_COPY_AND_ASSIGN(ColumnSet); |
| 370 }; | 379 }; |
| 371 | 380 |
| 372 } // namespace views | 381 } // namespace views |
| 373 | 382 |
| 374 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ | 383 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ |
| OLD | NEW |