OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_BOX_LAYOUT_H_ | 5 #ifndef VIEWS_BOX_LAYOUT_H_ |
6 #define VIEWS_BOX_LAYOUT_H_ | 6 #define VIEWS_BOX_LAYOUT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "views/layout_manager.h" | 10 #include "views/layout_manager.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 // A Layout manager that arranges child views vertically or horizontally in a | 14 // A Layout manager that arranges child views vertically or horizontally in a |
15 // side-by-side fashion with spacing around and between the child views. The | 15 // side-by-side fashion with spacing around and between the child views. The |
16 // child views are always sized according to their preferred size. If the | 16 // child views are always sized according to their preferred size. If the |
17 // host's bounds provide insufficient space, child views will be clamped. | 17 // host's bounds provide insufficient space, child views will be clamped. |
18 // Excess space will not be distributed. | 18 // Excess space will not be distributed. |
19 class BoxLayout : public LayoutManager { | 19 class BoxLayout : public LayoutManager { |
20 public: | 20 public: |
21 enum Orientation { | 21 enum Orientation { |
22 kHorizontal, | 22 kHorizontal, |
23 kVertical, | 23 kVertical, |
24 }; | 24 }; |
25 | 25 |
26 // Use |inside_border_spacing| to add additional space between the child view | 26 // Use |inside_border_horizontal_spacing| and |
27 // area and the host view border. |between_child_spacing| controls the space | 27 // |inside_border_vertical_spacing| to add additional space between the child |
28 // in between child views. | 28 // view area and the host view border. |between_child_spacing| controls the |
| 29 // space in between child views. |
29 BoxLayout(Orientation orientation, | 30 BoxLayout(Orientation orientation, |
30 int inside_border_spacing, | 31 int inside_border_horizontal_spacing, |
| 32 int inside_border_vertical_spacing, |
31 int between_child_spacing); | 33 int between_child_spacing); |
32 virtual ~BoxLayout() {} | 34 virtual ~BoxLayout() {} |
33 | 35 |
34 // Overridden from views::LayoutManager: | 36 // Overridden from views::LayoutManager: |
35 virtual void Layout(View* host); | 37 virtual void Layout(View* host); |
36 virtual gfx::Size GetPreferredSize(View* host); | 38 virtual gfx::Size GetPreferredSize(View* host); |
37 | 39 |
38 private: | 40 private: |
39 const Orientation orientation_; | 41 const Orientation orientation_; |
40 | 42 |
41 // Spacing between child views and host view border. | 43 // Spacing between child views and host view border. |
42 const int inside_border_spacing_; | 44 const int inside_border_horizontal_spacing_; |
| 45 const int inside_border_vertical_spacing_; |
| 46 |
43 // Spacing to put in between child views. | 47 // Spacing to put in between child views. |
44 const int between_child_spacing_; | 48 const int between_child_spacing_; |
45 | 49 |
46 DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout); | 50 DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout); |
47 }; | 51 }; |
48 | 52 |
49 } // namespace views | 53 } // namespace views |
50 | 54 |
51 #endif // VIEWS_BOX_LAYOUT_H_ | 55 #endif // VIEWS_BOX_LAYOUT_H_ |
OLD | NEW |