Fix a bug in RowColumnManager when adding / removing views to / from a layout.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41284 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2011-04-27 05:11:21 +00:00
parent 97a412ff15
commit efbd73e63d
2 changed files with 11 additions and 17 deletions

View File

@ -173,8 +173,6 @@ Area::SetLeft(XTab* left)
{
fLeft = left;
fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@ -194,8 +192,6 @@ Area::SetRight(XTab* right)
{
fRight = right;
fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@ -213,8 +209,6 @@ Area::SetTop(YTab* top)
{
fTop = top;
fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
@ -232,8 +226,6 @@ Area::SetBottom(YTab* bottom)
{
fBottom = bottom;
fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);

View File

@ -33,7 +33,7 @@ RowColumnManager::~RowColumnManager()
delete fColumns.ItemAt(i)->fPrefSizeConstraint;
}
void
RowColumnManager::AddArea(Area* area)
{
@ -41,16 +41,16 @@ RowColumnManager::AddArea(Area* area)
if (row == NULL) {
row = new Row(fLinearSpec, area->Top(), area->Bottom());
fRows.AddItem(row);
area->fRow = row;
}
area->fRow = row;
row->fAreas.AddItem(area);
Column* column = _FindColumnFor(area);
if (column == NULL) {
column = new Column(fLinearSpec, area->Left(), area->Right());
fColumns.AddItem(column);
area->fColumn = column;
}
area->fColumn = column;
column->fAreas.AddItem(area);
_UpdateConstraints(row);
@ -61,24 +61,26 @@ RowColumnManager::AddArea(Area* area)
void
RowColumnManager::RemoveArea(Area* area)
{
Row* row = _FindRowFor(area);
Row* row = area->fRow;
if (row) {
row->fAreas.RemoveItem(area);
area->fRow = NULL;
if (row->fAreas.CountItems() == 0) {
fRows.RemoveItem(row);
delete row;
} else
_UpdateConstraints(row);
}
_UpdateConstraints(row);
}
Column* column = _FindColumnFor(area);
Column* column = area->fColumn;
if (column) {
column->fAreas.RemoveItem(area);
area->fColumn = NULL;
if (column->fAreas.CountItems() == 0) {
fColumns.RemoveItem(column);
delete column;
} else
_UpdateConstraints(column);
}
_UpdateConstraints(column);
}
}