| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // An enumeration of the possible ways the size of a column may be obtained. | 93 // An enumeration of the possible ways the size of a column may be obtained. |
| 94 enum SizeType { | 94 enum SizeType { |
| 95 // The column size is fixed. | 95 // The column size is fixed. |
| 96 FIXED, | 96 FIXED, |
| 97 | 97 |
| 98 // The preferred size of the view is used to determine the column size. | 98 // The preferred size of the view is used to determine the column size. |
| 99 USE_PREF | 99 USE_PREF |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 explicit GridLayout(View* host); | 102 explicit GridLayout(View* host); |
| 103 virtual ~GridLayout(); | 103 ~GridLayout() override; |
| 104 | 104 |
| 105 // Creates a GridLayout with kPanel*Margin insets. | 105 // Creates a GridLayout with kPanel*Margin insets. |
| 106 static GridLayout* CreatePanel(View* host); | 106 static GridLayout* CreatePanel(View* host); |
| 107 | 107 |
| 108 // Sets the insets. All views are placed relative to these offsets. | 108 // Sets the insets. All views are placed relative to these offsets. |
| 109 void SetInsets(int top, int left, int bottom, int right); | 109 void SetInsets(int top, int left, int bottom, int right); |
| 110 void SetInsets(const gfx::Insets& insets); | 110 void SetInsets(const gfx::Insets& insets); |
| 111 | 111 |
| 112 // Creates a new column set with the specified id and returns it. | 112 // Creates a new column set with the specified id and returns it. |
| 113 // The id is later used when starting a new row. | 113 // The id is later used when starting a new row. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // pref_width/pref_height is > 0 then the preferred width/height of the view | 155 // pref_width/pref_height is > 0 then the preferred width/height of the view |
| 156 // is fixed to the specified value. | 156 // is fixed to the specified value. |
| 157 // As a convenience this adds the view to the host. The view becomes owned | 157 // As a convenience this adds the view to the host. The view becomes owned |
| 158 // by the host, and NOT this GridLayout. | 158 // by the host, and NOT this GridLayout. |
| 159 void AddView(View* view, int col_span, int row_span, | 159 void AddView(View* view, int col_span, int row_span, |
| 160 Alignment h_align, Alignment v_align, | 160 Alignment h_align, Alignment v_align, |
| 161 int pref_width, int pref_height); | 161 int pref_width, int pref_height); |
| 162 | 162 |
| 163 // Notification we've been installed on a particular host. Checks that host | 163 // Notification we've been installed on a particular host. Checks that host |
| 164 // is the same as the View supplied in the constructor. | 164 // is the same as the View supplied in the constructor. |
| 165 virtual void Installed(View* host) override; | 165 void Installed(View* host) override; |
| 166 | 166 |
| 167 // Notification we've been uninstalled on a particular host. Checks that host | 167 // Notification we've been uninstalled on a particular host. Checks that host |
| 168 // is the same as the View supplied in the constructor. | 168 // is the same as the View supplied in the constructor. |
| 169 virtual void Uninstalled(View* host) override; | 169 void Uninstalled(View* host) override; |
| 170 | 170 |
| 171 // Notification that a view has been added. | 171 // Notification that a view has been added. |
| 172 virtual void ViewAdded(View* host, View* view) override; | 172 void ViewAdded(View* host, View* view) override; |
| 173 | 173 |
| 174 // Notification that a view has been removed. | 174 // Notification that a view has been removed. |
| 175 virtual void ViewRemoved(View* host, View* view) override; | 175 void ViewRemoved(View* host, View* view) override; |
| 176 | 176 |
| 177 // Layouts out the components. | 177 // Layouts out the components. |
| 178 virtual void Layout(View* host) override; | 178 void Layout(View* host) override; |
| 179 | 179 |
| 180 // Returns the preferred size for the GridLayout. | 180 // Returns the preferred size for the GridLayout. |
| 181 virtual gfx::Size GetPreferredSize(const View* host) const override; | 181 gfx::Size GetPreferredSize(const View* host) const override; |
| 182 | 182 |
| 183 virtual int GetPreferredHeightForWidth(const View* host, | 183 int GetPreferredHeightForWidth(const View* host, int width) const override; |
| 184 int width) const override; | |
| 185 | 184 |
| 186 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; } | 185 void set_minimum_size(const gfx::Size& size) { minimum_size_ = size; } |
| 187 | 186 |
| 188 private: | 187 private: |
| 189 // As both Layout and GetPreferredSize need to do nearly the same thing, | 188 // As both Layout and GetPreferredSize need to do nearly the same thing, |
| 190 // they both call into this method. This sizes the Columns/Rows as | 189 // they both call into this method. This sizes the Columns/Rows as |
| 191 // appropriate. If layout is true, width/height give the width/height the | 190 // appropriate. If layout is true, width/height give the width/height the |
| 192 // of the host, otherwise they are ignored. | 191 // of the host, otherwise they are ignored. |
| 193 void SizeRowsAndColumns(bool layout, | 192 void SizeRowsAndColumns(bool layout, |
| 194 int width, | 193 int width, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // The master column of those columns that are linked. See Column | 366 // The master column of those columns that are linked. See Column |
| 368 // for a description of what the master column is. | 367 // for a description of what the master column is. |
| 369 std::vector<Column*> master_columns_; | 368 std::vector<Column*> master_columns_; |
| 370 | 369 |
| 371 DISALLOW_COPY_AND_ASSIGN(ColumnSet); | 370 DISALLOW_COPY_AND_ASSIGN(ColumnSet); |
| 372 }; | 371 }; |
| 373 | 372 |
| 374 } // namespace views | 373 } // namespace views |
| 375 | 374 |
| 376 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ | 375 #endif // UI_VIEWS_LAYOUT_GRID_LAYOUT_H_ |
| OLD | NEW |