Improve min constraints and add max constraints, not perfect yet but much better then before.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38643 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -752,8 +752,6 @@ SATGroup::AdjustWindows(SATWindow* triggerWindow)
|
|||||||
// set window locations and sizes
|
// set window locations and sizes
|
||||||
for (int i = 0; i < fSATWindowList.CountItems(); i++) {
|
for (int i = 0; i < fSATWindowList.CountItems(); i++) {
|
||||||
SATWindow* windowSAT = fSATWindowList.ItemAt(i);
|
SATWindow* windowSAT = fSATWindowList.ItemAt(i);
|
||||||
if (windowSAT == triggerWindow)
|
|
||||||
continue;
|
|
||||||
windowSAT->MoveWindowToSAT(
|
windowSAT->MoveWindowToSAT(
|
||||||
triggerWindow->GetWindow()->CurrentWorkspace());
|
triggerWindow->GetWindow()->CurrentWorkspace());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ GroupCookie::GroupCookie(SATWindow* satWindow)
|
|||||||
fTopConstraint(NULL),
|
fTopConstraint(NULL),
|
||||||
fMinWidthConstraint(NULL),
|
fMinWidthConstraint(NULL),
|
||||||
fMinHeightConstraint(NULL),
|
fMinHeightConstraint(NULL),
|
||||||
|
fMaxWidthConstraint(NULL),
|
||||||
|
fMaxHeightConstraint(NULL),
|
||||||
fWidthConstraint(NULL),
|
fWidthConstraint(NULL),
|
||||||
fHeightConstraint(NULL)
|
fHeightConstraint(NULL)
|
||||||
{
|
{
|
||||||
@@ -51,7 +53,7 @@ GroupCookie::~GroupCookie()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const uint32 kExtentPenalty = 25;
|
const uint32 kExtentPenalty = 10;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -71,6 +73,13 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
fLeftConstraint->SetRightSide(frame.left);
|
fLeftConstraint->SetRightSide(frame.left);
|
||||||
fTopConstraint->SetRightSide(frame.top);
|
fTopConstraint->SetRightSide(frame.top);
|
||||||
|
|
||||||
|
int32 minWidth, maxWidth, minHeight, maxHeight;
|
||||||
|
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
|
fMinWidthConstraint->SetRightSide(minWidth);
|
||||||
|
fMinHeightConstraint->SetRightSide(minHeight);
|
||||||
|
fMaxWidthConstraint->SetRightSide(maxWidth);
|
||||||
|
fMaxHeightConstraint->SetRightSide(maxHeight);
|
||||||
|
|
||||||
fWidthConstraint->SetPenaltyNeg(110);
|
fWidthConstraint->SetPenaltyNeg(110);
|
||||||
fWidthConstraint->SetPenaltyPos(110);
|
fWidthConstraint->SetPenaltyPos(110);
|
||||||
fHeightConstraint->SetPenaltyNeg(110);
|
fHeightConstraint->SetPenaltyNeg(110);
|
||||||
@@ -85,9 +94,7 @@ GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
|
|||||||
ResultType result;
|
ResultType result;
|
||||||
for (int32 tries = 0; tries < 15; tries++) {
|
for (int32 tries = 0; tries < 15; tries++) {
|
||||||
result = fSATGroup->GetLinearSpec()->Solve();
|
result = fSATGroup->GetLinearSpec()->Solve();
|
||||||
if (result == INFEASIBLE)
|
if (result == OPTIMAL || result == INFEASIBLE) {
|
||||||
break;
|
|
||||||
if (result == OPTIMAL) {
|
|
||||||
fSATGroup->AdjustWindows(triggerWindow);
|
fSATGroup->AdjustWindows(triggerWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -132,7 +139,6 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
|||||||
{
|
{
|
||||||
ASSERT(fSATGroup.Get() == NULL);
|
ASSERT(fSATGroup.Get() == NULL);
|
||||||
|
|
||||||
Window* window = fSATWindow->GetWindow();
|
|
||||||
fSATGroup.SetTo(group);
|
fSATGroup.SetTo(group);
|
||||||
fWindowArea = area;
|
fWindowArea = area;
|
||||||
|
|
||||||
@@ -157,11 +163,15 @@ GroupCookie::Init(SATGroup* group, WindowArea* area)
|
|||||||
OperatorType(EQ), frame.top, 1, 1);
|
OperatorType(EQ), frame.top, 1, 1);
|
||||||
|
|
||||||
int32 minWidth, maxWidth, minHeight, maxHeight;
|
int32 minWidth, maxWidth, minHeight, maxHeight;
|
||||||
window->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
fSATWindow->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||||
fMinWidthConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, -1.0,
|
fMinWidthConstraint = linearSpec->AddConstraint(1.0, fRightBorder, -1.0,
|
||||||
fRightBorder, OperatorType(LE), -minWidth);
|
fLeftBorder, OperatorType(GE), minWidth);
|
||||||
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fTopBorder, -1.0,
|
fMinHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
fBottomBorder, OperatorType(LE), -minHeight);
|
fTopBorder, OperatorType(GE), minHeight);
|
||||||
|
fMaxWidthConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
|
fTopBorder, OperatorType(LE), maxHeight);
|
||||||
|
fMaxHeightConstraint = linearSpec->AddConstraint(1.0, fBottomBorder, -1.0,
|
||||||
|
fTopBorder, OperatorType(LE), maxHeight);
|
||||||
|
|
||||||
// The width and height constraints have higher penalties than the
|
// The width and height constraints have higher penalties than the
|
||||||
// position constraints (left, top), so a window will keep its size
|
// position constraints (left, top), so a window will keep its size
|
||||||
@@ -220,12 +230,16 @@ GroupCookie::Uninit()
|
|||||||
delete fTopConstraint;
|
delete fTopConstraint;
|
||||||
delete fMinWidthConstraint;
|
delete fMinWidthConstraint;
|
||||||
delete fMinHeightConstraint;
|
delete fMinHeightConstraint;
|
||||||
|
delete fMaxWidthConstraint;
|
||||||
|
delete fMaxHeightConstraint;
|
||||||
delete fWidthConstraint;
|
delete fWidthConstraint;
|
||||||
delete fHeightConstraint;
|
delete fHeightConstraint;
|
||||||
fLeftConstraint = NULL;
|
fLeftConstraint = NULL;
|
||||||
fTopConstraint = NULL;
|
fTopConstraint = NULL;
|
||||||
fMinWidthConstraint = NULL;
|
fMinWidthConstraint = NULL;
|
||||||
fMinHeightConstraint = NULL;
|
fMinHeightConstraint = NULL;
|
||||||
|
fMaxWidthConstraint = NULL;
|
||||||
|
fMaxHeightConstraint = NULL;
|
||||||
fWidthConstraint = NULL;
|
fWidthConstraint = NULL;
|
||||||
fHeightConstraint = NULL;
|
fHeightConstraint = NULL;
|
||||||
|
|
||||||
@@ -480,6 +494,20 @@ SATWindow::CompleteWindowFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SATWindow::GetSizeLimits(int32* minWidth, int32* maxWidth, int32* minHeight,
|
||||||
|
int32* maxHeight) const
|
||||||
|
{
|
||||||
|
fWindow->GetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
|
|
||||||
|
// TODO get this values from the decorator
|
||||||
|
*minWidth += 11;
|
||||||
|
*minHeight += 11;
|
||||||
|
*maxWidth += 32;
|
||||||
|
*maxHeight += 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SATWindow::PositionManagedBySAT()
|
SATWindow::PositionManagedBySAT()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ private:
|
|||||||
Constraint* fTopConstraint;
|
Constraint* fTopConstraint;
|
||||||
Constraint* fMinWidthConstraint;
|
Constraint* fMinWidthConstraint;
|
||||||
Constraint* fMinHeightConstraint;
|
Constraint* fMinHeightConstraint;
|
||||||
|
Constraint* fMaxWidthConstraint;
|
||||||
|
Constraint* fMaxHeightConstraint;
|
||||||
Constraint* fWidthConstraint;
|
Constraint* fWidthConstraint;
|
||||||
Constraint* fHeightConstraint;
|
Constraint* fHeightConstraint;
|
||||||
};
|
};
|
||||||
@@ -103,6 +105,8 @@ public:
|
|||||||
|
|
||||||
//! \return the complete window frame including the Decorator
|
//! \return the complete window frame including the Decorator
|
||||||
BRect CompleteWindowFrame();
|
BRect CompleteWindowFrame();
|
||||||
|
void GetSizeLimits(int32* minWidth, int32* maxWidth,
|
||||||
|
int32* minHeight, int32* maxHeight) const;
|
||||||
|
|
||||||
//! \return true if window is in a group with a least another window
|
//! \return true if window is in a group with a least another window
|
||||||
bool PositionManagedBySAT();
|
bool PositionManagedBySAT();
|
||||||
|
|||||||
Reference in New Issue
Block a user