Keep the preferred size ratio into account. This make layout behaviour much more intuitive when resizing a window. Thanks Christof.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39641 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -151,6 +151,9 @@ private:
|
||||
float fSpacing;
|
||||
|
||||
Area* fCurrentArea;
|
||||
|
||||
Variable* fScaleWidth;
|
||||
Variable* fScaleHeight;
|
||||
};
|
||||
|
||||
} // namespace BALM
|
||||
|
||||
@@ -107,8 +107,12 @@ private:
|
||||
Area(BLayoutItem* item);
|
||||
|
||||
void _Init(LinearSpec* ls, XTab* left, YTab* top,
|
||||
XTab* right, YTab* bottom);
|
||||
void _Init(LinearSpec* ls, Row* row, Column* column);
|
||||
XTab* right, YTab* bottom,
|
||||
Variable* scaleWidth,
|
||||
Variable* scaleHeight);
|
||||
void _Init(LinearSpec* ls, Row* row, Column* column,
|
||||
Variable* scaleWidth,
|
||||
Variable* scaleHeight);
|
||||
|
||||
void _DoLayout();
|
||||
|
||||
@@ -145,6 +149,9 @@ private:
|
||||
double fContentAspectRatio;
|
||||
Constraint* fContentAspectRatioC;
|
||||
|
||||
Variable* fScaleWidth;
|
||||
Variable* fScaleHeight;
|
||||
|
||||
public:
|
||||
friend class BALMLayout;
|
||||
|
||||
|
||||
@@ -52,12 +52,16 @@ BALMLayout::BALMLayout(float spacing, BALMLayout* friendLayout)
|
||||
fPreferredSize = kUnsetSize;
|
||||
|
||||
fPerformancePath = NULL;
|
||||
|
||||
fScaleWidth = fSolver->AddVariable();
|
||||
fScaleHeight = fSolver->AddVariable();
|
||||
}
|
||||
|
||||
|
||||
BALMLayout::~BALMLayout()
|
||||
{
|
||||
|
||||
delete fScaleWidth;
|
||||
delete fScaleHeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +483,7 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* right,
|
||||
return NULL;
|
||||
fCurrentArea = area;
|
||||
|
||||
area->_Init(fSolver, left, top, right, bottom);
|
||||
area->_Init(fSolver, left, top, right, bottom, fScaleWidth, fScaleHeight);
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -494,7 +498,7 @@ BALMLayout::AddItem(BLayoutItem* item, Row* row, Column* column)
|
||||
return NULL;
|
||||
fCurrentArea = area;
|
||||
|
||||
area->_Init(fSolver, row, column);
|
||||
area->_Init(fSolver, row, column, fScaleWidth, fScaleHeight);
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
+19
-9
@@ -593,7 +593,8 @@ Area::Area(BLayoutItem* item)
|
||||
* Initialize variables.
|
||||
*/
|
||||
void
|
||||
Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom)
|
||||
Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom,
|
||||
Variable* scaleWidth, Variable* scaleHeight)
|
||||
{
|
||||
fLS = ls;
|
||||
fLeft = left;
|
||||
@@ -601,6 +602,9 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom)
|
||||
fTop = top;
|
||||
fBottom = bottom;
|
||||
|
||||
fScaleWidth = scaleWidth;
|
||||
fScaleHeight = scaleHeight;
|
||||
|
||||
// adds the two essential constraints of the area that make sure that the
|
||||
// left x-tab is really to the left of the right x-tab, and the top y-tab
|
||||
// really above the bottom y-tab
|
||||
@@ -612,11 +616,12 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom)
|
||||
fConstraints.AddItem(fMinContentWidth);
|
||||
fConstraints.AddItem(fMinContentHeight);
|
||||
|
||||
fPreferredContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight,
|
||||
OperatorType(EQ), 0, fShrinkPenalties.Height(), fGrowPenalties.Width());
|
||||
fPreferredContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, -1.0,
|
||||
fScaleWidth, OperatorType(EQ), 0, fShrinkPenalties.Height(),
|
||||
fGrowPenalties.Width());
|
||||
|
||||
fPreferredContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom,
|
||||
OperatorType(EQ), 0, fShrinkPenalties.Height(),
|
||||
fPreferredContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, -1.0,
|
||||
fScaleHeight, OperatorType(EQ), 0, fShrinkPenalties.Height(),
|
||||
fGrowPenalties.Height());
|
||||
|
||||
fConstraints.AddItem(fPreferredContentWidth);
|
||||
@@ -625,9 +630,11 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom)
|
||||
|
||||
|
||||
void
|
||||
Area::_Init(LinearSpec* ls, Row* row, Column* column)
|
||||
Area::_Init(LinearSpec* ls, Row* row, Column* column, Variable* scaleWidth,
|
||||
Variable* scaleHeight)
|
||||
{
|
||||
_Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom());
|
||||
_Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(),
|
||||
scaleWidth, scaleHeight);
|
||||
fRow = row;
|
||||
fColumn = column;
|
||||
}
|
||||
@@ -718,6 +725,9 @@ Area::_UpdatePreferredConstraint(BSize preferred)
|
||||
if (preferred.height > 0)
|
||||
height = preferred.Height() + TopInset() + BottomInset();
|
||||
|
||||
fPreferredContentWidth->SetRightSide(width);
|
||||
fPreferredContentHeight->SetRightSide(height);
|
||||
fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight, -width,
|
||||
fScaleWidth);
|
||||
|
||||
fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom, -height,
|
||||
fScaleHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user