Chromium Code Reviews| Index: ui/views/layout/box_layout.h |
| diff --git a/ui/views/layout/box_layout.h b/ui/views/layout/box_layout.h |
| index 54fa502eb569ef60643aaffd84962c3d326cfc7c..9af8e327d53645c39a2c2fda6198809e1e07a8ca 100644 |
| --- a/ui/views/layout/box_layout.h |
| +++ b/ui/views/layout/box_layout.h |
| @@ -5,6 +5,8 @@ |
| #ifndef UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ |
| #define UI_VIEWS_LAYOUT_BOX_LAYOUT_H_ |
| +#include <map> |
| + |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| #include "ui/gfx/insets.h" |
| @@ -38,11 +40,6 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager { |
| MAIN_AXIS_ALIGNMENT_START, |
| MAIN_AXIS_ALIGNMENT_CENTER, |
| MAIN_AXIS_ALIGNMENT_END, |
| - |
| - // This distributes extra space among the child views. This increases the |
| - // size of child views along the main axis rather than the space between |
| - // them. |
| - MAIN_AXIS_ALIGNMENT_FILL, |
| // TODO(calamity): Add MAIN_AXIS_ALIGNMENT_JUSTIFY which spreads blank space |
| // in-between the child views. |
|
sashab
2014/07/01 06:52:04
Is this TODO still needed? This can be emulated wi
calamity
2014/07/01 08:19:44
This TODO outlines spreading the blank space to th
|
| }; |
| @@ -80,6 +77,19 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager { |
| inside_border_insets_ = insets; |
| } |
| + void set_default_flex(int flex) { default_flex_ = flex; } |
|
sashab
2014/07/01 06:52:04
Is there a reason these methods use underscores an
calamity
2014/07/01 08:19:44
Setting a property verbatim can be inlined and uni
|
| + |
| + // Sets the flex weight for the view at |index|. This uses the preferred main |
| + // axis size as a basis and then distributes any free space along the main |
| + // axis to the views in the ratio of the flex weights. If the views will |
| + // overflow the parent in the main axis, this subtracts space from the views |
| + // in the ratio of the flex weights. |
| + void SetFlexForViewAt(int index, int flex); |
|
sashab
2014/07/01 06:52:04
Can flex be negative? Maybe add 'The flex cannot b
calamity
2014/07/01 08:19:44
Done.
|
| + |
| + // Clears the flex for the view at |index|, causing it to use the default |
| + // flex. |
| + void ClearFlexForViewAt(int index); |
| + |
| // Overridden from views::LayoutManager: |
| virtual void Layout(View* host) OVERRIDE; |
| virtual gfx::Size GetPreferredSize(const View* host) const OVERRIDE; |
| @@ -87,6 +97,9 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager { |
| int width) const OVERRIDE; |
| private: |
| + // Returns the flex for the specified index. |
|
sashab
2014/07/01 06:52:04
Nit: 'Returns the flex *for the view*...'
calamity
2014/07/01 08:19:44
I think this is disingenuous as it implies the fle
|
| + int GetFlexForViewAt(int index); |
| + |
| // Returns the size and position along the main axis of |rect|. |
| int MainAxisSize(const gfx::Rect& rect) const; |
| int MainAxisPosition(const gfx::Rect& rect) const; |
| @@ -134,6 +147,12 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager { |
| // CROSS_AXIS_ALIGNMENT_STRETCH by default. |
| CrossAxisAlignment cross_axis_alignment_; |
| + // A map of view indexes to flex weights. |
| + std::map<int, int> flex_map_; |
| + |
| + // The flex weight for views if none is set. |
|
sashab
2014/07/01 06:52:04
Add to this comment 'Defaults to 0.'
calamity
2014/07/01 08:19:44
Done.
|
| + int default_flex_; |
| + |
| DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout); |
| }; |