| 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..30f72a0f7dbd957156952ae61d6b226378497508 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.
|
| };
|
| @@ -80,6 +77,22 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager {
|
| inside_border_insets_ = insets;
|
| }
|
|
|
| + void set_default_flex(int flex) { default_flex_ = flex; }
|
| +
|
| + // Sets the flex weight for the view at |index|. Using the preferred size as
|
| + // the basis, free space along the main axis is distributed to views in the
|
| + // ratio of their flex weights. Similarly, if the views will overflow the
|
| + // parent, space is subtracted in these ratios.
|
| + // NB Flex weights are set for the index, not the actual view.
|
| + //
|
| + // A flex of 0 means this view is not resized. Flex values must not be
|
| + // negative.
|
| + void SetFlexForViewAt(int index, int flex);
|
| +
|
| + // 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 +100,9 @@ class VIEWS_EXPORT BoxLayout : public LayoutManager {
|
| int width) const OVERRIDE;
|
|
|
| private:
|
| + // Returns the flex for the specified index.
|
| + 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 +150,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. Defaults to 0.
|
| + int default_flex_;
|
| +
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout);
|
| };
|
|
|
|
|