OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/layout/box_layout.h" | 5 #include "views/layout/box_layout.h" |
6 | 6 |
| 7 #include "gfx/insets.h" |
| 8 #include "gfx/rect.h" |
| 9 #include "views/view.h" |
| 10 |
7 namespace views { | 11 namespace views { |
8 | 12 |
9 BoxLayout::BoxLayout(BoxLayout::Orientation orientation, | 13 BoxLayout::BoxLayout(BoxLayout::Orientation orientation, |
10 int inside_border_horizontal_spacing, | 14 int inside_border_horizontal_spacing, |
11 int inside_border_vertical_spacing, | 15 int inside_border_vertical_spacing, |
12 int between_child_spacing) | 16 int between_child_spacing) |
13 : orientation_(orientation), | 17 : orientation_(orientation), |
14 inside_border_horizontal_spacing_(inside_border_horizontal_spacing), | 18 inside_border_horizontal_spacing_(inside_border_horizontal_spacing), |
15 inside_border_vertical_spacing_(inside_border_vertical_spacing), | 19 inside_border_vertical_spacing_(inside_border_vertical_spacing), |
16 between_child_spacing_(between_child_spacing) { | 20 between_child_spacing_(between_child_spacing) { |
17 } | 21 } |
18 | 22 |
| 23 BoxLayout::~BoxLayout() { |
| 24 } |
| 25 |
19 void BoxLayout::Layout(View* host) { | 26 void BoxLayout::Layout(View* host) { |
20 gfx::Rect childArea(gfx::Rect(host->size())); | 27 gfx::Rect childArea(gfx::Rect(host->size())); |
21 childArea.Inset(host->GetInsets()); | 28 childArea.Inset(host->GetInsets()); |
22 childArea.Inset(inside_border_horizontal_spacing_, | 29 childArea.Inset(inside_border_horizontal_spacing_, |
23 inside_border_vertical_spacing_); | 30 inside_border_vertical_spacing_); |
24 int x = childArea.x(); | 31 int x = childArea.x(); |
25 int y = childArea.y(); | 32 int y = childArea.y(); |
26 for (int i = 0; i < host->GetChildViewCount(); ++i) { | 33 for (int i = 0; i < host->GetChildViewCount(); ++i) { |
27 View* child = host->GetChildViewAt(i); | 34 View* child = host->GetChildViewAt(i); |
28 if (child->IsVisible()) { | 35 if (child->IsVisible()) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 position += between_child_spacing_; | 67 position += between_child_spacing_; |
61 } | 68 } |
62 } | 69 } |
63 gfx::Insets insets(host->GetInsets()); | 70 gfx::Insets insets(host->GetInsets()); |
64 return gfx::Size( | 71 return gfx::Size( |
65 bounds.width() + insets.width() + 2 * inside_border_horizontal_spacing_, | 72 bounds.width() + insets.width() + 2 * inside_border_horizontal_spacing_, |
66 bounds.height() + insets.height() + 2 * inside_border_vertical_spacing_); | 73 bounds.height() + insets.height() + 2 * inside_border_vertical_spacing_); |
67 } | 74 } |
68 | 75 |
69 } // namespace views | 76 } // namespace views |
OLD | NEW |