From 8ef1944247c77e7d68ba1ce73aa0f2206ba6f08e Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Sat, 18 Jun 2011 01:12:29 +0000 Subject: [PATCH] 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 --- headers/os/interface/LayoutBuilder.h | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/headers/os/interface/LayoutBuilder.h b/headers/os/interface/LayoutBuilder.h index 10e639b6cf..83e8824b16 100644 --- a/headers/os/interface/LayoutBuilder.h +++ b/headers/os/interface/LayoutBuilder.h @@ -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::Group(BWindow* window, enum orientation orientation, } +template +Group::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 Group::Group(BGroupLayout* layout) : @@ -617,6 +635,18 @@ Grid::Grid(BWindow* window, float horizontalSpacing, } +template +Grid::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 Grid::Grid(BGridLayout* layout) :