Also update the preferred size constraints correctly when replacing the tabs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39644 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2010-11-26 04:33:06 +00:00
parent 5cfaa5ee78
commit c97cd0f4da
2 changed files with 26 additions and 11 deletions

View File

@ -118,7 +118,10 @@ private:
void _UpdateMinSizeConstraint(BSize min); void _UpdateMinSizeConstraint(BSize min);
void _UpdateMaxSizeConstraint(BSize max); void _UpdateMaxSizeConstraint(BSize max);
void _UpdatePreferredConstraint(BSize preferred); void _UpdatePreferredWidthConstraint(
BSize& preferred);
void _UpdatePreferredHeightConstraint(
BSize& preferred);
private: private:
BLayoutItem* fLayoutItem; BLayoutItem* fLayoutItem;

View File

@ -174,7 +174,9 @@ Area::SetLeft(XTab* left)
fColumn = NULL; fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); BSize preferredSize = fLayoutItem->PreferredSize();
_UpdatePreferredWidthConstraint(preferredSize);
if (fMaxContentWidth != NULL) if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@ -195,7 +197,8 @@ Area::SetRight(XTab* right)
fColumn = NULL; fColumn = NULL;
fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMinContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); BSize preferredSize = fLayoutItem->PreferredSize();
_UpdatePreferredWidthConstraint(preferredSize);
if (fMaxContentWidth != NULL) if (fMaxContentWidth != NULL)
fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight);
@ -214,7 +217,8 @@ Area::SetTop(YTab* top)
fRow = NULL; fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); BSize preferredSize = fLayoutItem->PreferredSize();
_UpdatePreferredHeightConstraint(preferredSize);
if (fMaxContentHeight != NULL) if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
@ -233,7 +237,8 @@ Area::SetBottom(YTab* bottom)
fRow = NULL; fRow = NULL;
fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMinContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); BSize preferredSize = fLayoutItem->PreferredSize();
_UpdatePreferredHeightConstraint(preferredSize);
if (fMaxContentHeight != NULL) if (fMaxContentHeight != NULL)
fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom);
@ -540,7 +545,8 @@ Area::InvalidateSizeConstraints()
_UpdateMinSizeConstraint(minSize); _UpdateMinSizeConstraint(minSize);
_UpdateMaxSizeConstraint(maxSize); _UpdateMaxSizeConstraint(maxSize);
_UpdatePreferredConstraint(prefSize); _UpdatePreferredWidthConstraint(prefSize);
_UpdatePreferredHeightConstraint(prefSize);
} }
@ -716,17 +722,23 @@ Area::_UpdateMaxSizeConstraint(BSize max)
void void
Area::_UpdatePreferredConstraint(BSize preferred) Area::_UpdatePreferredWidthConstraint(BSize& preferred)
{ {
float width = 32000; float width = 32000;
float height = 32000;
if (preferred.width > 0) if (preferred.width > 0)
width = preferred.Width() + LeftInset() + RightInset(); width = preferred.Width() + LeftInset() + RightInset();
if (preferred.height > 0)
height = preferred.Height() + TopInset() + BottomInset();
fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight, -width, fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight, -width,
fScaleWidth); fScaleWidth);
}
void
Area::_UpdatePreferredHeightConstraint(BSize& preferred)
{
float height = 32000;
if (preferred.height > 0)
height = preferred.Height() + TopInset() + BottomInset();
fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom, -height, fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom, -height,
fScaleHeight); fScaleHeight);