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
-8
View File
@@ -173,8 +173,6 @@ Area::SetLeft(XTab* left)
{ {
fLeft = left; fLeft = left;
fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
if (fMaxContentWidth != NULL) if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@@ -194,8 +192,6 @@ Area::SetRight(XTab* right)
{ {
fRight = right; fRight = right;
fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
if (fMaxContentWidth != NULL) if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@@ -213,8 +209,6 @@ Area::SetTop(YTab* top)
{ {
fTop = top; fTop = top;
fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
if (fMaxContentHeight != NULL) if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
@@ -232,8 +226,6 @@ Area::SetBottom(YTab* bottom)
{ {
fBottom = bottom; fBottom = bottom;
fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
if (fMaxContentHeight != NULL) if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
+10 -8
View File
@@ -41,16 +41,16 @@ RowColumnManager::AddArea(Area* area)
if (row == NULL) { if (row == NULL) {
row = new Row(fLinearSpec, area->Top(), area->Bottom()); row = new Row(fLinearSpec, area->Top(), area->Bottom());
fRows.AddItem(row); fRows.AddItem(row);
area->fRow = row;
} }
area->fRow = row;
row->fAreas.AddItem(area); row->fAreas.AddItem(area);
Column* column = _FindColumnFor(area); Column* column = _FindColumnFor(area);
if (column == NULL) { if (column == NULL) {
column = new Column(fLinearSpec, area->Left(), area->Right()); column = new Column(fLinearSpec, area->Left(), area->Right());
fColumns.AddItem(column); fColumns.AddItem(column);
area->fColumn = column;
} }
area->fColumn = column;
column->fAreas.AddItem(area); column->fAreas.AddItem(area);
_UpdateConstraints(row); _UpdateConstraints(row);
@@ -61,24 +61,26 @@ RowColumnManager::AddArea(Area* area)
void void
RowColumnManager::RemoveArea(Area* area) RowColumnManager::RemoveArea(Area* area)
{ {
Row* row = _FindRowFor(area); Row* row = area->fRow;
if (row) { if (row) {
row->fAreas.RemoveItem(area); row->fAreas.RemoveItem(area);
area->fRow = NULL;
if (row->fAreas.CountItems() == 0) { if (row->fAreas.CountItems() == 0) {
fRows.RemoveItem(row); fRows.RemoveItem(row);
delete row; delete row;
} else }
_UpdateConstraints(row); _UpdateConstraints(row);
} }
Column* column = _FindColumnFor(area); Column* column = area->fColumn;
if (column) { if (column) {
column->fAreas.RemoveItem(area); column->fAreas.RemoveItem(area);
area->fColumn = NULL;
if (column->fAreas.CountItems() == 0) { if (column->fAreas.CountItems() == 0) {
fColumns.RemoveItem(column); fColumns.RemoveItem(column);
delete column; delete column;
} else }
_UpdateConstraints(column); _UpdateConstraints(column);
} }
} }