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 #include "ui/views/layout/box_layout.h" | 5 #include "ui/views/layout/box_layout.h" |
6 | 6 |
7 #include "ui/gfx/rect.h" | 7 #include "ui/gfx/rect.h" |
8 #include "ui/views/view.h" | 8 #include "ui/views/view.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 return GetPreferredSizeForChildWidth(host, width); | 95 return GetPreferredSizeForChildWidth(host, width); |
96 } | 96 } |
97 | 97 |
98 int BoxLayout::GetPreferredHeightForWidth(View* host, int width) { | 98 int BoxLayout::GetPreferredHeightForWidth(View* host, int width) { |
99 int child_width = width - NonChildSize(host).width(); | 99 int child_width = width - NonChildSize(host).width(); |
100 return GetPreferredSizeForChildWidth(host, child_width).height(); | 100 return GetPreferredSizeForChildWidth(host, child_width).height(); |
101 } | 101 } |
102 | 102 |
| 103 void BoxLayout::OnChildPreferredSizeChanged(View* host, View* child) { |
| 104 HostPreferredSizeShouldChange(host); |
| 105 } |
| 106 |
103 gfx::Size BoxLayout::GetPreferredSizeForChildWidth(View* host, | 107 gfx::Size BoxLayout::GetPreferredSizeForChildWidth(View* host, |
104 int child_area_width) { | 108 int child_area_width) { |
105 gfx::Rect child_area_bounds; | 109 gfx::Rect child_area_bounds; |
106 | 110 |
107 if (orientation_ == kHorizontal) { | 111 if (orientation_ == kHorizontal) { |
108 // Horizontal layouts ignore |child_area_width|, meaning they mimic the | 112 // Horizontal layouts ignore |child_area_width|, meaning they mimic the |
109 // default behavior of GridLayout::GetPreferredHeightForWidth(). | 113 // default behavior of GridLayout::GetPreferredHeightForWidth(). |
110 // TODO(estade): fix this if it ever becomes a problem. | 114 // TODO(estade): fix this if it ever becomes a problem. |
111 int position = 0; | 115 int position = 0; |
112 for (int i = 0; i < host->child_count(); ++i) { | 116 for (int i = 0; i < host->child_count(); ++i) { |
(...skipping 27 matching lines...) Expand all Loading... |
140 child_area_bounds.height() + non_child_size.height()); | 144 child_area_bounds.height() + non_child_size.height()); |
141 } | 145 } |
142 | 146 |
143 gfx::Size BoxLayout::NonChildSize(View* host) { | 147 gfx::Size BoxLayout::NonChildSize(View* host) { |
144 gfx::Insets insets(host->GetInsets()); | 148 gfx::Insets insets(host->GetInsets()); |
145 return gfx::Size(insets.width() + inside_border_insets_.width(), | 149 return gfx::Size(insets.width() + inside_border_insets_.width(), |
146 insets.height() + inside_border_insets_.height()); | 150 insets.height() + inside_border_insets_.height()); |
147 } | 151 } |
148 | 152 |
149 } // namespace views | 153 } // namespace views |
OLD | NEW |