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_BOX_LAYOUT_H_ | 5 #ifndef UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ |
6 #define UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ | 6 #define UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/gfx/insets.h" | 10 #include "ui/gfx/insets.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 // child views are always sized according to their preferred size. If the | 23 // child views are always sized according to their preferred size. If the |
24 // host's bounds provide insufficient space, child views will be clamped. | 24 // host's bounds provide insufficient space, child views will be clamped. |
25 // Excess space will not be distributed. | 25 // Excess space will not be distributed. |
26 class VIEWS_EXPORT BoxLayout : public LayoutManager { | 26 class VIEWS_EXPORT BoxLayout : public LayoutManager { |
27 public: | 27 public: |
28 enum Orientation { | 28 enum Orientation { |
29 kHorizontal, | 29 kHorizontal, |
30 kVertical, | 30 kVertical, |
31 }; | 31 }; |
32 | 32 |
33 enum BoxPack { | |
34 BOX_PACK_START, | |
35 BOX_PACK_CENTER, | |
36 BOX_PACK_END, | |
37 }; | |
38 | |
33 // Use |inside_border_horizontal_spacing| and | 39 // Use |inside_border_horizontal_spacing| and |
34 // |inside_border_vertical_spacing| to add additional space between the child | 40 // |inside_border_vertical_spacing| to add additional space between the child |
35 // view area and the host view border. |between_child_spacing| controls the | 41 // view area and the host view border. |between_child_spacing| controls the |
36 // space in between child views. | 42 // space in between child views. |
37 BoxLayout(Orientation orientation, | 43 BoxLayout(Orientation orientation, |
38 int inside_border_horizontal_spacing, | 44 int inside_border_horizontal_spacing, |
39 int inside_border_vertical_spacing, | 45 int inside_border_vertical_spacing, |
40 int between_child_spacing); | 46 int between_child_spacing); |
41 virtual ~BoxLayout(); | 47 virtual ~BoxLayout(); |
42 | 48 |
43 void set_spread_blank_space(bool spread) { | 49 void set_spread_blank_space(bool spread) { |
44 spread_blank_space_ = spread; | 50 spread_blank_space_ = spread; |
45 } | 51 } |
46 | 52 |
53 void set_box_pack(BoxPack box_pack) { box_pack_ = box_pack; } | |
benwells
2014/05/13 02:48:05
Comment what this is, and mention what the default
calamity
2014/05/13 04:29:29
Is the member comment not enough?
| |
54 | |
47 // Overridden from views::LayoutManager: | 55 // Overridden from views::LayoutManager: |
48 virtual void Layout(View* host) OVERRIDE; | 56 virtual void Layout(View* host) OVERRIDE; |
49 virtual gfx::Size GetPreferredSize(View* host) OVERRIDE; | 57 virtual gfx::Size GetPreferredSize(View* host) OVERRIDE; |
50 virtual int GetPreferredHeightForWidth(View* host, int width) OVERRIDE; | 58 virtual int GetPreferredHeightForWidth(View* host, int width) OVERRIDE; |
51 | 59 |
52 private: | 60 private: |
53 // The preferred size for the dialog given the width of the child area. | 61 // The preferred size for the dialog given the width of the child area. |
54 gfx::Size GetPreferredSizeForChildWidth(View* host, int child_area_width); | 62 gfx::Size GetPreferredSizeForChildWidth(View* host, int child_area_width); |
55 | 63 |
56 // The amount of space the layout requires in addition to any space for the | 64 // The amount of space the layout requires in addition to any space for the |
57 // child views. | 65 // child views. |
58 gfx::Size NonChildSize(View* host); | 66 gfx::Size NonChildSize(View* host); |
59 | 67 |
60 const Orientation orientation_; | 68 const Orientation orientation_; |
61 | 69 |
62 // Spacing between child views and host view border. | 70 // Spacing between child views and host view border. |
63 gfx::Insets inside_border_insets_; | 71 gfx::Insets inside_border_insets_; |
64 | 72 |
65 // Spacing to put in between child views. | 73 // Spacing to put in between child views. |
66 const int between_child_spacing_; | 74 const int between_child_spacing_; |
67 | 75 |
68 // Whether the available extra space should be distributed among the child | 76 // Whether the available extra space should be distributed among the child |
69 // views. | 77 // views. |
70 bool spread_blank_space_; | 78 bool spread_blank_space_; |
71 | 79 |
80 // The alignment of children in the main axis. | |
81 BoxPack box_pack_; | |
82 | |
72 DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout); | 83 DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout); |
73 }; | 84 }; |
74 | 85 |
75 } // namespace views | 86 } // namespace views |
76 | 87 |
77 #endif // UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ | 88 #endif // UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ |
OLD | NEW |