From 574533ef124f30d7710ce46ade1ca5f05935e083 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 16 Jan 2012 12:36:51 +1300 Subject: [PATCH] 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. --- headers/libs/alm/ALMLayout.h | 3 +-- src/libs/alm/ALMLayout.cpp | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/headers/libs/alm/ALMLayout.h b/headers/libs/alm/ALMLayout.h index b8931c7c6e..c7ba0276d1 100644 --- a/headers/libs/alm/ALMLayout.h +++ b/headers/libs/alm/ALMLayout.h @@ -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(); diff --git a/src/libs/alm/ALMLayout.cpp b/src/libs/alm/ALMLayout.cpp index 31381dd194..d1e878adf3 100644 --- a/src/libs/alm/ALMLayout.cpp +++ b/src/libs/alm/ALMLayout.cpp @@ -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); }