Add new constructors to BLayoutBuilder::Grid and BLayoutBuilder::Group that accept a plain old BView, and give it a new layout. These are very similar to the constructors that are already in place taking a BWindow. This solves a problem I have come across a few times, where one wants to build a layout in something like a BBox. Althought there is currently a way to do it with the layout builders, this is prettier.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42224 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alex Wilson 2011-06-18 01:12:29 +00:00
parent ab6b173770
commit 8ef1944247

View File

@ -61,6 +61,9 @@ public:
inline Group(BWindow* window,
enum orientation orientation = B_HORIZONTAL,
float spacing = B_USE_DEFAULT_SPACING);
inline Group(BView* view,
enum orientation orientation = B_HORIZONTAL,
float spacing = B_USE_DEFAULT_SPACING);
inline Group(BGroupLayout* layout);
inline Group(BGroupView* view);
@ -127,6 +130,9 @@ public:
inline Grid(BWindow* window,
float horizontal = B_USE_DEFAULT_SPACING,
float vertical = B_USE_DEFAULT_SPACING);
inline Grid(BView* view,
float horizontal = B_USE_DEFAULT_SPACING,
float vertical = B_USE_DEFAULT_SPACING);
inline Grid(BGridLayout* layout);
inline Grid(BGridView* view);
@ -359,6 +365,18 @@ Group<ParentBuilder>::Group(BWindow* window, enum orientation orientation,
}
template<typename ParentBuilder>
Group<ParentBuilder>::Group(BView* view, enum orientation orientation,
float spacing)
:
fLayout(new BGroupLayout(orientation, spacing))
{
view->SetLayout(fLayout);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
}
template<typename ParentBuilder>
Group<ParentBuilder>::Group(BGroupLayout* layout)
:
@ -617,6 +635,18 @@ Grid<ParentBuilder>::Grid(BWindow* window, float horizontalSpacing,
}
template<typename ParentBuilder>
Grid<ParentBuilder>::Grid(BView* view, float horizontalSpacing,
float verticalSpacing)
:
fLayout(new BGridLayout(horizontalSpacing, verticalSpacing))
{
view->SetLayout(fLayout);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// TODO: we get a white background if we don't do this
}
template<typename ParentBuilder>
Grid<ParentBuilder>::Grid(BGridLayout* layout)
: