| Index: ui/views/layout/box_layout.cc
|
| diff --git a/ui/views/layout/box_layout.cc b/ui/views/layout/box_layout.cc
|
| index 7282431685715c1efd8f510b1dd057821b73b590..4db0677141d08e66ecee35386c7b6b8aebbcf65f 100644
|
| --- a/ui/views/layout/box_layout.cc
|
| +++ b/ui/views/layout/box_layout.cc
|
| @@ -17,7 +17,8 @@ BoxLayout::BoxLayout(BoxLayout::Orientation orientation,
|
| : orientation_(orientation),
|
| inside_border_horizontal_spacing_(inside_border_horizontal_spacing),
|
| inside_border_vertical_spacing_(inside_border_vertical_spacing),
|
| - between_child_spacing_(between_child_spacing) {
|
| + between_child_spacing_(between_child_spacing),
|
| + spread_blank_space_(false) {
|
| }
|
|
|
| BoxLayout::~BoxLayout() {
|
| @@ -30,17 +31,45 @@ void BoxLayout::Layout(View* host) {
|
| inside_border_vertical_spacing_);
|
| int x = child_area.x();
|
| int y = child_area.y();
|
| +
|
| + int padding = 0;
|
| + if (spread_blank_space_) {
|
| + int total = 0;
|
| + int visible = 0;
|
| + for (int i = 0; i < host->child_count(); ++i) {
|
| + View* child = host->child_at(i);
|
| + if (!child->visible())
|
| + continue;
|
| + if (orientation_ == kHorizontal)
|
| + total += child->GetPreferredSize().width() + between_child_spacing_;
|
| + else
|
| + total += child->GetPreferredSize().height() + between_child_spacing_;
|
| + ++visible;
|
| + }
|
| +
|
| + if (visible) {
|
| + total -= between_child_spacing_;
|
| + if (orientation_ == kHorizontal)
|
| + padding = (child_area.width() - total) / visible;
|
| + else
|
| + padding = (child_area.height() - total) / visible;
|
| +
|
| + if (padding < 0)
|
| + padding = 0;
|
| + }
|
| + }
|
| +
|
| for (int i = 0; i < host->child_count(); ++i) {
|
| View* child = host->child_at(i);
|
| if (child->visible()) {
|
| gfx::Rect bounds(x, y, child_area.width(), child_area.height());
|
| gfx::Size size(child->GetPreferredSize());
|
| if (orientation_ == kHorizontal) {
|
| - bounds.set_width(size.width());
|
| - x += size.width() + between_child_spacing_;
|
| + bounds.set_width(size.width() + padding);
|
| + x += size.width() + between_child_spacing_ + padding;
|
| } else {
|
| - bounds.set_height(size.height());
|
| - y += size.height() + between_child_spacing_;
|
| + bounds.set_height(size.height() + padding);
|
| + y += size.height() + between_child_spacing_ + padding;
|
| }
|
| // Clamp child view bounds to |child_area|.
|
| child->SetBoundsRect(bounds.Intersect(child_area));
|
|
|