In BALMLayout, make AddView(...) consistent with other layouts.

If a BView is added which has a BLayout, use the layout as a BLayoutItem
to represent that view, as other layouts do.
This commit is contained in:
Alex Wilson 2012-01-16 12:36:51 +13:00
parent 9b0221fd43
commit 574533ef12
2 changed files with 22 additions and 15 deletions

View File

@ -150,8 +150,7 @@ private:
float InsetForTab(XTab* tab);
float InsetForTab(YTab* tab);
/*! Add a view without initialize the Area. */
BLayoutItem* _CreateLayoutItem(BView* view);
BLayoutItem* _LayoutItemToAdd(BView* view);
void _UpdateAreaConstraints();

View File

@ -451,10 +451,11 @@ Area*
BALMLayout::AddView(BView* view, XTab* left, YTab* top, XTab* right,
YTab* bottom)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItem(item, left, top, right, bottom);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -472,10 +473,11 @@ BALMLayout::AddView(BView* view, XTab* left, YTab* top, XTab* right,
Area*
BALMLayout::AddView(BView* view, Row* row, Column* column)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItem(item, row, column);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -485,10 +487,11 @@ BALMLayout::AddView(BView* view, Row* row, Column* column)
Area*
BALMLayout::AddViewToRight(BView* view, XTab* right, YTab* top, YTab* bottom)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItemToRight(item, right, top, bottom);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -498,10 +501,11 @@ BALMLayout::AddViewToRight(BView* view, XTab* right, YTab* top, YTab* bottom)
Area*
BALMLayout::AddViewToLeft(BView* view, XTab* left, YTab* top, YTab* bottom)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItemToLeft(item, left, top, bottom);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -511,10 +515,11 @@ BALMLayout::AddViewToLeft(BView* view, XTab* left, YTab* top, YTab* bottom)
Area*
BALMLayout::AddViewToTop(BView* view, YTab* top, XTab* left, XTab* right)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItemToTop(item, top, left, right);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -524,10 +529,11 @@ BALMLayout::AddViewToTop(BView* view, YTab* top, XTab* left, XTab* right)
Area*
BALMLayout::AddViewToBottom(BView* view, YTab* bottom, XTab* left, XTab* right)
{
BLayoutItem* item = _CreateLayoutItem(view);
BLayoutItem* item = _LayoutItemToAdd(view);
Area* area = AddItemToBottom(item, bottom, left, right);
if (!area) {
delete item;
if (item != view->GetLayout())
delete item;
return NULL;
}
return area;
@ -1074,8 +1080,10 @@ BALMLayout::InsetForTab(YTab* tab)
BLayoutItem*
BALMLayout::_CreateLayoutItem(BView* view)
BALMLayout::_LayoutItemToAdd(BView* view)
{
if (view->GetLayout())
return view->GetLayout();
return new(std::nothrow) BViewLayoutItem(view);
}